?
Solved

Yes No Messagebox

Posted on 2004-10-13
2
Medium Priority
?
284 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
[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
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

765 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