In visual basic, the Return statement is useful to terminate the execution of the method in which it appears and return the control back to the calling method.
Generally, in visual basic, the Return statement is useful whenever we want to value the other methods. We can also omit the usage of return statement in our methods by using void as a return type.
Following is the syntax of using Return statement in a visual basic programming language.
If you observe the above syntax, we used Return keyword as return type, and the value parameter return_val is used to return the value. The return_val parameter value can be either string or integer or array or list of object based on our requirements.
Now, we will see how to use Return statement in a visual basic programming language with examples.
Following is the example of using Return statement in a visual basic programming language.
If you observe the above code, we used Return statement in the SumofNumbers method. Here, whenever we call SumofNumbers method it will execute and return the resultant value using Return statement.
We will get the following result when we execute the above visual basic program.
This is how we can use Return statement in a visual basic programming language based on our requirements.