msgbox cancel button is not working

Joined
Nov 7, 2008
Messages
20
Programming Experience
Beginner
VB.NET:
If (name.text = "") Then
          MsgBox("Record Does not exist", MsgBoxStyle.OkCancel)
            If  MsgBoxResult.Cancel Then
                form1.Show()
                Me.Close()
            End If
        End If


=================================================

When I press cancel button of msgbox it should load form1 and close current form.......But it is not working like that, It does not load form1 and nor show current form......Please help
 
You're not assigning the result of the MsgBox anywhere and expecting it to work.
VB.NET:
        If (name.text = "") Then
            If MessageBox.Show("Record Does not exist", "Invalid Record", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) = Windows.Forms.DialogResult.Cancel Then
                Form1.Show()
                Me.Close()
            End If
        End If
Thread moved to VB Gen
 
Back
Top