Solved

Yes No Messagebox

Posted on 2004-10-13
2
277 Views
Last Modified: 2010-04-24
Using the code below, how can I default the focus to the No instead of to the Yes option on the messagebox when it opens?

Dim msg As String = "All data will be permanently lost." & vbCrLf & "Are you sure you want to delete the data file?"
        If MessageBox.Show(msg, "Deleting Data File", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then
            NumericUpDown1.Focus()
            If File.Exists(fileName) Then
                File.Delete(fileName)
                MsgBox("File Deleted", MsgBoxStyle.Information, "Delete Data File")
                analyzeNumbers()
            End If
        End If
0
Comment
Question by:teamdad
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 12302212
Like this (note the extra parameter after MessageBoxIcon.Warning) :

        Dim msg As String = "All data will be permanently lost." & vbCrLf & "Are you sure you want to delete the data file?"
        If MessageBox.Show(msg, "Deleting Data File", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
            NumericUpDown1.Focus()
            If File.Exists(fileName) Then
                File.Delete(fileName)
                MsgBox("File Deleted", MsgBoxStyle.Information, "Delete Data File")
                analyzeNumbers()
            End If
        End If
0
 

Author Comment

by:teamdad
ID: 12302300
Thanks again Idle_Mind for the help.  I learn better from doing and seeing than reading and then trying to apply what I read.  It's tough learning as you go like this but it's best for me.  I have another question on doing a file backup if you would like to check it out too.  It's at the link below.

http://experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21167308.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

14 Experts available now in Live!

Get 1:1 Help Now