How do I return a result from a function?
For example:
Public Function test() As Integer
return 1
End Function
This gives a compile error.
How do I make this function return an integer?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For non-object return types, you have to assign the value to the name of your function, like this:
Example usage:
If the function returns an Object type, then you must use the
Setkeyword like this:Example usage:
Note that assigning a return value to the function name does not terminate the execution of your function. If you want to exit the function, then you need to explicitly say
Exit Function. For example:Documentation: Function Statement