0

In C# if you wanted to return out of a function you could do:

If (Something == True)
{
   //Message Box
   Return;
}
Else
{
   // Do nothing
}

How would one do this is VB 6?

1 Answer 1

7

In VB6, you write

FunctionName = ReturnValue

Yes, seriously.

To stop execution of a function, use Exit Function (or Exit Sub)

Sign up to request clarification or add additional context in comments.

4 Comments

+1. And it's because the Return statement in VB6 relates to the GoSub statement, which was dropped for VB.Net. Use of GoSub is frowned on in VB6.
That's not "why" at all. The "why" is that Basic was designed to follow the precedents set by both Fortran and Algol which influenced Basic's development.
@Bob77 True. I wasn't giving a complete history of the language development. I simply meant to provide a brief explanation for the OP, who apparently is a C# developer with little knowledge of Basic, and might otherwise get confused by compiler errors when using a Return statement without any GoSub.
Fair enough. I'm constantly amazed anyone assigns all these carpentry tasks to plumbers though.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.