Link to home
Start Free TrialLog in
Avatar of yongyih
yongyihFlag for Malaysia

asked on

Messagebox question. (with Yes to all, Not to all button)

Avatar of zzzzzooc
zzzzzooc

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/messagebox.asp

As per the MSDN documentation for MessageBox, "yes to all" and "no to all" is not supported. You'll have to create your own form with Command Buttons and use it to act as a MessageBox. You can do this by using the vbModal option in the Show() method of a Form.

Example..

Private Sub Form_Load()
    Call Form1.Show
    Call Form2.Show(vbModal)
End Sub
ASKER CERTIFIED SOLUTION
Avatar of dbrckovi
dbrckovi
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can make this function more flexible by replacing it with this:
It will allow you to specify button captions.

Function myMsgBox(ByVal Message As String, ByVal Title As String, ByVal Caption1 As String, Caption2 As String)
    Load Form2
    Form2.Top = Screen.Height / 2 - Form2.Height / 2
    Form2.Left = Screen.Width / 2 - Form2.Width / 2
    Form2.Label1.Caption = Message
    Form2.Caption = Title
    Form2.Command1.Caption = Caption1
    Form2.Command2.Caption = Caption2
    Form2.Show (vbModal)
    myMsgBox = Form2.Response
    Unload Form2
End Function

Private Sub Command1_Click()
    Print myMsgBox("Select an option. First button will return True" & Chr(13) & "and the second one False", "Question", "Yes To All", "No To All")
End Sub
thanks