VB Functon as Sub

Jan 09, 2007 0 Replies

Example of Function called as Sub:



'MsgBox function return "OK" or "cancel" to variable "retLong" retLong = MsgBox("OK to proceed", vbOKCancel)



'MsgBox function called as Sub, with no return variable MsgBox "OK to proceed?", vbOKCancel



Both of these will have the same external behavior, pausing the program to get input. Only the first allows you to see what the user selected. Long values for vbOK (=1) or vbCancel (=2) are returned to the variable "retLong" based on user selection.



Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required