locked
How do I show a confirmation box instead of a MessageBox? RRS feed

  • Question

  • I am trying to find a relatively simple way of showing a MessageBox with a "Yes" and "No"(Confirmation box).  Can anyone help me please?
    Tuesday, September 5, 2006 6:45 AM

Answers

  •   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim answer As DialogResult
        answer = MessageBox.Show("Was nobugz here?", "Yes/no sample", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If answer = vbYes Then
          Debug.Print("He waz")
        End If
      End Sub

    Tuesday, September 5, 2006 7:29 AM
    Moderator

All replies

  • Create your own dialog form and place the "Yes" and "No" button there and set the DialogResult property of the button accordingly. and use this form to work as a message box. and show it calling the ShowDialog Method.
    Tuesday, September 5, 2006 6:51 AM
  • This is how i do it
    MsgBox("Message To Display", MsgBoxStyle.YesNo, "Title")

    if you can go

    if MsgBox("Message To Display", MsgBoxStyle.YesNo, "Title") = MsgBoxResult.Yes then
    .
    .
    .
    End if

    HTH
    Andrew
    Tuesday, September 5, 2006 6:56 AM
  • MsgBox is the VB6 way of showing the messagebox. But in vb.net it is replaced with MessageBox. So If You are working in VB.Net then use it's provided method. But there is no problem in using MsgBox because it is still supproted by .net.
    Tuesday, September 5, 2006 7:05 AM
  •   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim answer As DialogResult
        answer = MessageBox.Show("Was nobugz here?", "Yes/no sample", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If answer = vbYes Then
          Debug.Print("He waz")
        End If
      End Sub

    Tuesday, September 5, 2006 7:29 AM
    Moderator
  • Thanks nobugz.
    Tuesday, September 5, 2006 7:47 AM