Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Default button from Msgbox

Posted on 2004-10-20
1
Medium Priority
?
263 Views
Last Modified: 2012-05-05
How can I set the default button from Msgbox ?

Thanks !
0
Comment
Question by:vbhaha
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 750 total points
ID: 12366130
Using MsgBox you can't.  It is a carry over from VB6.

You can specify the default button using the .Net version, MessageBox():

Overloads Public Shared Function Show( _
   ByVal text As String, _
   ByVal caption As String, _
   ByVal buttons As MessageBoxButtons, _
   ByVal icon As MessageBoxIcon, _
   ByVal defaultButton As MessageBoxDefaultButton _
) As DialogResult

For example:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If MessageBox.Show("Are you sure?", "Delete all files", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
            ' delete files...
        End If
    End Sub

This displays a YesNo dialog with No as the default.

~IM
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month7 days, 2 hours left to enroll

782 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