Solved

Yes No Messagebox

Posted on 2004-10-13
2
275 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

12 Experts available now in Live!

Get 1:1 Help Now