Click to See Complete Forum and Search --> : MsgBox Problem
Apprentice
July 13th, 2001, 03:24 PM
I can get a message box to pop up using the MsgBox Function, but if I try to add any other parameters besides the prompt, I get this:
Compile error:
Expected: =
All I wanted was to specify the title. Here is the code I wrote:
MsgBox("There is an error.", ,"WARNING")
Can someone tell me what I'm doing wrong? Thanks.
The more you know, the more you know you don't know.
Ghost308
July 13th, 2001, 03:33 PM
Try it like this...
MsgBox "Message", , "Message Title"
Apprentice
July 13th, 2001, 03:38 PM
That worked perfectly, thanks! I guess it was those brackets hanging me up.
The more you know, the more you know you don't know.
michi
July 13th, 2001, 04:09 PM
If you do want to use brackets, try this:
Call MsgBox("There is an error.", ,"WARNING")
This is because you use Option Explicit.
Regards,
Michi
MCSE, MCDBA
Apprentice
July 13th, 2001, 04:35 PM
Cool, that works too! But I didn't type Option Explicit into my code. Could my VB design environment be using it automatically I wonder?
The more you know, the more you know you don't know.
michi
July 13th, 2001, 05:46 PM
I made a mistake just now. It is VB system not "Option Explicit" that not allow brackets without "Call" when there is no return value or you don't want to get it. But in VB.NET, the need for the Call word will be removed. Let's look and see.
Regards,
Michi
MCSE, MCDBA
pellybelly
July 13th, 2001, 06:08 PM
Yea, Option Explicit has nothing to do with brackets used in calling functions. Option Explicit has to do with variables being declared before initialization.
Brackets will be used in calling a function when prefixed with the "Call" directive, or when used in an equasion. For example
Call MsgBox("Hello World")
Dim Response
Response = MsgBox("Hello World")
You should get used to using the "Call" directive and using brackets when calling functions. It is common in almost every other programming language, and will be implemented in VB.NET
Good luck!
John Peloquin
Peloweb.com
john@peloweb.com
"Always remember to lock your keys in your car so little elves don't come and steal them out of your pocket" - Alexander Graham Bell
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.