This results in a syntax error:
Sub test()
MsgBox("hello world", vbOKCancel) ' syntax error at this line
Exit Sub
End Sub
Why?
You're just using the MsgBox method as a Sub. In VB6/VBA a Sub call either doesn't use brackets, or uses the Call keyword.
MsgBox "hello world", vbOKCancel
or
Call MsgBox("hello world", vbOKCancel)
The brackets come into play when using the method as a function (ie you want the return value)
Dim msgResult
msgResult = MsgBox("hello world", vbOKCancel)
I would guess that, since you're using vbOKCancel, this is the version you'll end up using to find out what the user clicked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With