Private Sub SetFormErrorState()
Dim errorMessage As String = Nothing
'Checking CC# for numeric
If Not Me.ValidateTextBox(Me.phoneTextBox.Text) Then
'The user has not entered the required value.
errorMessage = "Entry Required"
'Checking phone for numeric
Me.ErrorProvider.SetError(Me.phoneTextBox, errorMessage)
ElseIf Me.ccTextBox.Enabled AndAlso Not Me.ValidateTextBox(Me.ccTextBox.Text) Then
'The user has not entered the required value.
errorMessage = "Entry Required"
Me.ErrorProvider.SetError(Me.ccTextBox, errorMessage)
ElseIf Not Me.ValidateTextBox(Me.startMiTextBox.Text) Then
'The user has not entered the required value.
errorMessage = "Entry Required"
Me.ErrorProvider.SetError(Me.startMiTextBox, errorMessage)
ElseIf Not Me.ValidateTextBox(Me.endMiTextBox.Text) Then
'The user has not entered the required value.
errorMessage = "Entry Required"
Me.ErrorProvider.SetError(Me.endMiTextBox, errorMessage)
ElseIf Not Me.ValidateTextBox(Me.daysRentedTextBox.Text) Then
'The user has not entered the required value.
errorMessage = "Entry Required"
Me.ErrorProvider.SetError(Me.daysRentedTextBox, errorMessage)
Else
Me.ErrorProvider.Clear()
End If
'Enable the OK button if and only if there are no errors.
Me.calculateButton.Enabled = (errorMessage Is Nothing)
End Sub
Private Function ValidateTextBox(ByVal varTextBoxString As String) As Boolean
If varTextBoxString = "" Then
Return False
Else
Return True
End If
'Return True if the TextBox contains any value, otherwise return False.
End Function