Visual Basic (not "for Applications") message boxs

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
I knwo this doesn't quite belong in this forum, but I really need a solution as quick as I can get one, and I don't belong to any other forums like this one.

I'm trying to use a message box in a proprietary application that uses VB, but I get an error that says "Wrong number of parameters".

Code:
a = MsgBox (Err.Number, vbOkOnly, "Error #")

Help, anyone
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I thought it was the msgbox statement, but it's the err statement. It works differently in VB than in VBA.

My night ends at 2 PST. Can anyone help me out with this?
 
Upvote 0
According to this site the syntax for a VB message box is:
http://visualbasic.freetutes.com/learn-vb6/lesson18.html

MsgBox ( Prompt [,icons+buttons ] [,title ] )

From you error message it looks like you are missing the icon arguemnt, i.e.,
vbQuestion + vbOkOnly
vbCritical + vbOkOnly

Check your application help file for MsgBox Function.

NB
When you enclose a MsgBox arguments within parenthesis the value returned will be the number of the Button the user clicks. The variable receiving the argument has to of the appropriate data type.

Code:
[COLOR=darkblue]Sub[/COLOR] test1()
   [COLOR=darkblue]Dim[/COLOR] a [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]
 
   a = MsgBox(Err.Number, vbInformation + vbOKOnly, "Error #")
 
   [COLOR=green]' a = vbOKOnly = 1[/COLOR]
   MsgBox "You clicked button: " & a
 
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,719
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top