Results 1 to 7 of 7

Thread: Is there a "return()" call in VB6?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    Home
    Posts
    85

    Is there a "return()" call in VB6?

    I am pretty sure there is not, but it would be quite useful if someone has a work around for this to return a value to the function that is processing the command.

    Now that I am starting to work with Java and C++ I enjoy the (at times) simplicity of some commands. One being return();

    I think they implemented this statement in VB.net 03 or 05 but perhaps there is one in vb6 that I just never have seen?

    Why is it better? Dont have to repeat the function name. ex: instead of GetString = sString it could be return(sString).

    Anyway, let me know if you think there is or is not, and if you have seen, think you know of, or found a work around instead of calling the function name again.

    I mean it is not a big deal to retype the name, but hey, it prvides an easier outline and allows for better reusablilty.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Is there a "return()" call in VB6?

    No, not in the sense that I believe that you mean (as it C++)

    You can get a Return from a Function, however, to repeatedly get the return you need to repeatedly call the function.

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Is there a "return()" call in VB6?

    There is no Return() like there is in Java, PHP, C++, etc. It's just the FunctionName = Something to return the value.

    Not sure why VB did it like this, and it can be kind of a pain after being used to a language like PHP/C++ that uses return().

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Is there a "return()" call in VB6?

    Quote Originally Posted by DigiRev
    Not sure why VB did it like this, and it can be kind of a pain after being used to a language like PHP/C++ that uses return().
    I can see that. My exposure to Return was the reverse.

    I started out with VB and then went into C++ - it took a moment for my VB addled brain to understand what Return meant in C++. When it finally did sink in, I was more than just a little annoyed that VB didn't have it.

  5. #5
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,948

    Re: Is there a "return()" call in VB6?

    Don't you mean "Return" that is found in some what an for, next and return statement block.

    I do remember using the Return command in an For .... Next Block of code, that I had used many months ago.

  6. #6
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Is there a "return()" call in VB6?

    Return in VB (not net) is used in conjunction with GoSub. Gah !

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Is there a "return()" call in VB6?

    There is a 'gotcha' at work here. In Visual Basic 6, wrapping any value in brackets causes it to be passed by value rather than by reference, if the ByRef or ByVal keywords are not explicitly specified. The statement Return (value) can thus cause unexpected behaviour if you are not aware of this caveat. It is safest to always omit brackets where they are unnecessary.


    The brackets are not necessary in any C-based language either. In fact it is good style to omit them, as the presence or absence of brackets clearly distinguishes, respectively, the use of a function versus a language statement.

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