I am trying to open two different forms depending on if I click yes or no from a message box. The code runs but both yes and no open the same form. Is it possible to open two different forms? My code is posted below.

Both open Form3 when clicked. Thanks mbrown686886

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Nickname?", MsgBoxStyle.YesNo)
'This code will open the Form3
If MsgBoxResult.Yes Then
Form3 = Nothing
Form3.Show()
'This code will open the Form9
ElseIf MsgBoxResult.No Then
Form9 = Nothing
Form9.Show()
End If
End Sub

Dim myCoolMsgBox As DialogResult '// declare a message box.
        myCoolMsgBox = MessageBox.Show("Nickname?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        Select Case myCoolMsgBox
            Case DialogResult.Yes
                MsgBox("You pressed Yes.")
            Case DialogResult.No
                MsgBox("You pressed No.")
        End Select
   Dim myCoolMsgBox As DialogResult '// declare a message box.
    myCoolMsgBox = MessageBox.Show("Nickname?", Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question)

   Select Case myCoolMsgBox
        Case DialogResult.Yes
            MsgBox("You pressed Yes.")
        Case DialogResult.No
            MsgBox("You pressed No.")
    End Select

This did the trick. I owe you one. Thanks a million. I will marked as solved.
mbrown686886

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.