|
-
Aug 16th, 2001, 09:42 PM
#1
Thread Starter
Lively Member
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
-
Aug 16th, 2001, 09:44 PM
#2
Frenzied Member
-
Aug 16th, 2001, 09:48 PM
#3
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
-
Aug 17th, 2001, 07:59 AM
#4
PowerPoster
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
-
Aug 17th, 2001, 08:37 AM
#5
Simply whenever you want to call the code which is in function "Fight" just either use:
or
That will execute all codes which is part of the function "Fight".
-
Aug 17th, 2001, 08:46 AM
#6
PowerPoster
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
-
Aug 17th, 2001, 08:54 AM
#7
Addicted Member
If iHitPoints <= iLowHP_ItsCurtainsForMe Then
FightToTheDeath()
Else
GoToLocalShopsAndBuyHealingPotions()
End IF
-
Aug 17th, 2001, 10:59 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|