Solved

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

Posted on 2004-04-08
4
475 Views
Last Modified: 2008-03-17
0
Comment
Question by:yongyih
  • 3
4 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now