[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-04-08
4
Medium Priority
?
513 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 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses

649 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