By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

Intentional Error on Boolean

P: 8
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,Finally function I'm using to CATCH it. How do I intentionally create and error catch on a boolean FALSE.

Private Sub TextBox1_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Validated
Dim aNumber As String = CStr(TextBox1.Text)
Dim text As Boolean = isInteger(aNumber)
MsgBox("You Entered " & aNumber)
If text = False Then
End If

MsgBox("Please enter an Integer.")
Me.TextBox1.Select(Me.TextBox1.Text.Length, 1)
End Try
End Sub
Function isInteger(ByVal strVal As String) As Boolean

'if not numeric or decimal point found
If Not IsNumeric(strVal) Or InStr(strVal, ".") Then
isInteger = False
isInteger = True
End If
End Function
Apr 19 '07 #1
Share this Question
Share on Google+
2 Replies

P: 103
if you are intrested in any error you could do something like this
Expand|Select|Wrap|Line Numbers
  1. dim bool as boolean
  2. bool = "two"
this should produce a Type Mismatch error
Apr 19 '07 #2

P: 8
Thanks. I did something similar.
Apr 19 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.