I would like to enable a button after all of the necessary data is entered. After all of the data is entered, it needs to write to file. I have this code:
However, the button isn't enabling after all of the fields have data entered and the text file is saving before the data gets entered. Is there a better way to write this code?
Code:
Private Sub btnAccept_Handles(sender As System.Object, e As System.EventArgs) Handles btnAccept.HandleCreated
If (txtCustName.Text <> "") And (txtCustStAdd.Text <> "") And (txtCustAddCity.Text <> "") And (cboState.SelectedItem <> "") And (mtbZip.Text <> "") And (mtbCustPh.Text <> "") Then
btnAccept.Enabled = True
Else
btnAccept.Enabled = False
End If
Dim SaveFile As New SaveFileDialog
SaveFile.FileName = "Customer Log File"
SaveFile.Filter = "Transactional Log File (*.txt)|*.txt"
SaveFile.Title = "Save File"
SaveFile.ShowDialog()
Try
Dim Write As New System.IO.StreamWriter(SaveFile.FileName)
Write.Write(txtCustName.Text)
Write.Close()
Catch ex As Exception
End Try
End Sub