I'm using an "isInteger" function to test and input. The isInteger function returns a boolean response. If this response is FALSE I would like the Try,Catch,Final ly function I'm using to CATCH it. How do I intentionally create and error catch on a boolean FALSE.
<code>
Private Sub TextBox1_Valida ted(ByVal sender As Object, ByVal e As System.EventArg s) Handles TextBox1.Valida ted
Try
Dim aNumber As String = CStr(TextBox1.T ext)
Dim text As Boolean = isInteger(aNumb er)
MsgBox("You Entered " & aNumber)
If text = False Then
INSERT ERROR HERE
End If
Catch
MsgBox("Please enter an Integer.")
Me.TextBox1.Foc us()
Me.TextBox1.Sel ect(Me.TextBox1 .Text.Length, 1)
Finally
End Try
End Sub
Function isInteger(ByVal strVal As String) As Boolean
'if not numeric or decimal point found
If Not IsNumeric(strVa l) Or InStr(strVal, ".") Then
isInteger = False
Else
isInteger = True
End If
End Function
<code>
Private Sub TextBox1_Valida ted(ByVal sender As Object, ByVal e As System.EventArg s) Handles TextBox1.Valida ted
Try
Dim aNumber As String = CStr(TextBox1.T ext)
Dim text As Boolean = isInteger(aNumb er)
MsgBox("You Entered " & aNumber)
If text = False Then
INSERT ERROR HERE
End If
Catch
MsgBox("Please enter an Integer.")
Me.TextBox1.Foc us()
Me.TextBox1.Sel ect(Me.TextBox1 .Text.Length, 1)
Finally
End Try
End Sub
Function isInteger(ByVal strVal As String) As Boolean
'if not numeric or decimal point found
If Not IsNumeric(strVa l) Or InStr(strVal, ".") Then
isInteger = False
Else
isInteger = True
End If
End Function
Comment