Results 1 to 8 of 8

Thread: Easy question

  1. #1

    Thread Starter
    Lively Member DeBauer's Avatar
    Join Date
    May 2001
    Location
    Mako Reactor #7
    Posts
    123

    Question Easy question

    How do I go to a function?

    I tried "goto fight" but I get an error. How do I make it go to that function at the end of another command, and do everything in that function?



    Public Function fight() As String
    end function




    -thanks

  2. #2
    Frenzied Member numtel's Avatar
    Join Date
    Apr 2000
    Location
    CA
    Posts
    1,163
    Just type "fight"

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You don't really 'goto' a function you just run it.

    VB Code:
    1. 'blah, blah, blah
    2. 'end of code
    3. x=fight
    4. 'x will then become the value that the fight function returns
    5. 'or if its a sub then
    6. fight

  4. #4
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi, here is a little example if it makes it easier to understand
    Regards
    Stuart
    VB Code:
    1. Private Sub text1_Validate(Cancel As Boolean)
    2.       text1.text = FnFormatProper(text1.text)
    3. End Sub
    4.  
    5. Function FnFormatProper(lstrText As String) As String
    6.     FnFormatProper = StrConv(lstrText, vbProperCase)
    7. End Function
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  5. #5
    j2k
    Guest
    Simply whenever you want to call the code which is in function "Fight" just either use:

    VB Code:
    1. Fight

    or

    VB Code:
    1. Call Fight

    That will execute all codes which is part of the function "Fight".

  6. #6
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi
    Yeah but J2k u r using a function there as a subroutine and i was assuming that the poster wanted to use a function and hence return a value
    regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  7. #7
    Addicted Member
    Join Date
    Jul 2001
    Posts
    158
    If iHitPoints <= iLowHP_ItsCurtainsForMe Then
    FightToTheDeath()
    Else
    GoToLocalShopsAndBuyHealingPotions()
    End IF

  8. #8
    j2k
    Guest
    Originally posted by beachbum
    Hi
    Yeah but J2k u r using a function there as a subroutine and i was assuming that the poster wanted to use a function and hence return a value
    regards
    Stuart
    Yeah I was assuming he wanted a subroutine... Namely because he tried the GoTo command to try to Go To the function and execute the commands... My way will work if you are wanting a subroutine but like beachbum said, not if you want a "function" as such.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width