tags:

views:

44

answers:

3

Hi Dear friends

How to create MsgBox with two options in VB script

For example

The Msg Box include two buttons

  1. the first button name: ON
  2. the second button name: OFF

THX

Yael

A: 

Cannot be done. MsgBox buttons can only have specific values.
You'll have to roll your own form for this.

To create a MsgBox with two options (Yes/No):

MsgBox("Some Text", vbYesNo)
Sani Huttunen
if not how to create with VB two option button?Yael
yael
A: 

The VBScript Messagebox is fairly limited as to the labels you can apply to the buttons, your choices are pretty much limited to:

  • OK
  • Cancel
  • Retry
  • Abort
  • Ignore
  • Yes
  • No

So you are going to have to build your own form if you want "ON"/"OFF"

Better yet, why not rephrase the prompt in the box so one of the above options works.

For example:

Do you want the light on? 
[Yes] [No]

And for God's sake don't do one of these UI monstrosities!

Switch setting? (Click "yes" for ON and "No" for Off)
[Yes] [No]
JohnFx
A: 

You probably want to do something like this:

result = MsgBox ("Yes or No?", vbYesNo, "Yes No Example")

Select Case result
Case vbYes
    MsgBox("You chose Yes")
Case vbNo
    MsgBox("You chose No")
End Select
Sam Johnson
Can I change the word on the button from yes to other string?
yael
No, but as JohnFx suggested, you could rephrase the statement in your message box so that the "Yes" and "No" options would work.
Sam Johnson