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
Printable View
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
Just type "fight"
You don't really 'goto' a function you just run it.
VB Code:
'blah, blah, blah 'end of code x=fight 'x will then become the value that the fight function returns 'or if its a sub then fight
Hi, here is a little example if it makes it easier to understand
Regards
Stuart
VB Code:
Private Sub text1_Validate(Cancel As Boolean) text1.text = FnFormatProper(text1.text) End Sub Function FnFormatProper(lstrText As String) As String FnFormatProper = StrConv(lstrText, vbProperCase) End Function
Simply whenever you want to call the code which is in function "Fight" just either use:
VB Code:
Fight
or
VB Code:
Call Fight
That will execute all codes which is part of the function "Fight".
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
If iHitPoints <= iLowHP_ItsCurtainsForMe Then
FightToTheDeath()
Else
GoToLocalShopsAndBuyHealingPotions()
End IF
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.Quote:
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