[RESOLVED] [02/03] 2 Issues with Custom Dialog Form
Form3 is my dialog box called from a command button in form1.
Form 3 Code:
Code:
Public Class Form3
Inherits System.Windows.Forms.Form
Public ReadOnly Property MySpeed() As String
Get
Return Me.cmbSpeed.SelectedText.ToString
End Get
End Property
Private Sub okSpdBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles okSpdBtn.Click
Me.DialogResult = Windows.Forms.DialogResult.OK
End Sub
Private Sub cnclSpdBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cnclSpdBtn.Click
Me.DialogResult = Windows.Forms.DialogResult.Cancel
End Sub
End Class
Command Button Code from form1
Code:
Private Sub btnSpeed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSpeed.Click
If frm2 Is Nothing Then
MsgBox("Please start display before changing settings.")
Else
frm3 = New Form3()
frm3.ShowDialog()
If frm3.ShowDialog() = Windows.Forms.DialogResult.OK Then
Debug.WriteLine("Speed: " & frm3.MySpeed)
Else
' User clicked the Cancel button
End If
frm2.Refresh()
End If
End Sub
My 2 issues:
1. The dialog box does not close when the user clicks the "ok" or "cancel" button. (It does close when clicked a 2nd time)
2. I do not see any ouput from my Debug.WriteLine("Speed: " & frm3.MySpeed) statement for frm3.MySpeed
Thanks for your help in advance
Re: [02/03] 2 Issues with Custom Dialog Form
I think I fixed the 2nd issue, however I still need to hit ok or cancel twice for the form to close ??? :confused:
Re: [02/03] 2 Issues with Custom Dialog Form
Well I guess I have to answer my own question.
I needed to delete frm3.ShowDialog() because it appears in the IF statement so it is repetitive.