|
-
Feb 6th, 2008, 12:49 PM
#1
Thread Starter
Lively Member
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.
-
Feb 6th, 2008, 12:53 PM
#2
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.
-
Feb 6th, 2008, 12:58 PM
#3
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().
-
Feb 6th, 2008, 01:02 PM
#4
Re: Is there a "return()" call in VB6?
 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.
-
Feb 6th, 2008, 08:31 PM
#5
PowerPoster
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.
-
Feb 7th, 2008, 04:56 AM
#6
Re: Is there a "return()" call in VB6?
Return in VB (not net) is used in conjunction with GoSub. Gah !
-
Feb 7th, 2008, 05:01 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|