Intentional Error on Boolean

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmoeller
    New Member
    • Apr 2007
    • 8

    Intentional Error on Boolean

    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
  • Tig201
    New Member
    • Mar 2007
    • 103

    #2
    if you are intrested in any error you could do something like this
    Code:
    dim bool as boolean
    bool = "two"
    this should produce a Type Mismatch error

    Comment

    • mmoeller
      New Member
      • Apr 2007
      • 8

      #3
      Thanks. I did something similar.

      Comment

      Working...