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?
Printable View
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?
learn by example...
VB Code:
Public Function AddOne(i As Integer) As Integer AddOne = i +1 'this is the return End Sub
:)
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.
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.
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