Results 1 to 5 of 5

Thread: Return value from a function?

  1. #1
    nottheboss
    Guest

    Question 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?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    learn by example...
    VB Code:
    1. Public Function AddOne(i As Integer) As Integer
    2.   AddOne = i +1 'this is the return
    3. End Sub

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    WorkHorse
    Guest
    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.

  4. #4
    WorkHorse
    Guest
    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.

  5. #5
    nottheboss
    Guest
    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
  •  



Click Here to Expand Forum to Full Width