VB messagebox yes / no我想要' no'关闭消息框,但它关闭我要打开的表单

时间:2018-05-04 18:20:55

标签: vb.net messagebox

Private Sub btnMain_Click(sender As Object, e As EventArgs) Handles btnMain.Click
    Dim result As DialogResult = MessageBox.Show("Did you save customer info?", "Save Information", MessageBoxButtons.YesNo, MessageBoxIcon.Stop)
    If (result = DialogResult.Yes) Then
        'Me.Visible = False
        Me.Close()
        frmDuneTours.Visible = True
    ElseIf (result = DialogResult.No) Then
        frmDuneTours.Visible = False
        Me.Visible = True
    End If
End Sub

1 个答案:

答案 0 :(得分:0)

当你放置Me.Close之前 frmDuneTours.Visible = True 第二行永远不会执行,因为当你关闭当前表单时,应用程序结束。

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim result As DialogResult = MessageBox.Show("Did you save customer info?", "Save Information", MessageBoxButtons.YesNo, MessageBoxIcon.Stop)
        If (result = DialogResult.Yes) Then
            frmSortedList.Visible = True
            Me.Close()
        ElseIf (result = DialogResult.No) Then
            frmSortedList.Visible = False
        End If
End Sub