|
-
Dec 27th, 2001, 10:19 PM
#1
Return value from a function?
I've asked this b4 and I forgot... so first off... does anyone know how I can find my way back to old threads I started? (I've erased all the email notifications)
How do you return a value from a function?
-
Dec 27th, 2001, 10:25 PM
#2
learn by example...
VB Code:
Public Function AddOne(i As Integer) As Integer
AddOne = i +1 'this is the return
End Sub
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 27th, 2001, 10:37 PM
#3
To get your old posts, open your profile, then click on "Search for all posts by this user" in the upper right (which doesn't look like a link but it is). That will show everything you have posted.
-
Dec 27th, 2001, 11:00 PM
#4
A function returns a value. That is, the returned vaule is the value set to the function name. Think about: MyStr = Right("TEXT", 2). "Right" is a built in function. When it runs, you pass variables in the parenthesis. The "Right" function takes those variables, runs some code, and assigns (in this case) Right = "XT". So the "Right" function returns the vaule of "XT". You have coded to have MyStr = 'the function return vaule of Right'. Since the return vaule is "XT": MyStr = "XT". Your own functions return vaules in the same way. So when you code a function, set the value you want to return equal to the function name. Your code will propably be something like X = myfunction(stuff, stuff, stuff). So myfunction should be coded to set myfunction = the vaule that should be assigned to X.
I don't know if this is crystal or mud, but it's one way of looking at it.
-
Dec 27th, 2001, 11:03 PM
#5
Thank you all very much.
I understand VB functions now and my program is getting closer and closer to the being functional.... but i've still got a lot of ground to cover.
This forum rocks.
-Eric
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
|