Solved

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

Posted on 2004-04-08
4
488 Views
Last Modified: 2008-03-17
0
Comment
Question by:yongyih
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10789328
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
0
 
LVL 11

Accepted Solution

by:
dbrckovi earned 50 total points
ID: 10790127
Create new form ( Form2 )
Place label and two command buttons ( set Their captions to "Yes to All" and "No to all" )

Paste this code to form1:
----------------------------------
Function myMsgBox(ByVal Message As String, ByVal Title 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.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")
End Sub
----------------------------------
and this to form2
----------------------------------
Public Response As Boolean

Private Sub Command1_Click()
    Response = True
    Me.Hide
End Sub

Private Sub Command2_Click()
    Response = False
    Me.Hide
End Sub

Private Sub Form_Activate()
    Response = False
End Sub
------------------------------------------
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 10790141
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
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 10796359
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB6 / DAO 3.6 / run time error: Couldn't find installable ISAM 7 117
Exit a vb6 apps when a calling it apps closes 15 58
Spell Check in VB6 13 137
Export Data to Different .csv Files 26 121
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question