Hi all I'm new to VB.net, and need a little help writing a try/catch block. I'm trying to catch any negative number entered into a text field called txtAmount.Text. If the number entered is negative a meesage box shows indicating a positive number needs entered.
Catch Err As Exception When (CInt(txtAmount.Text)) < 0
MessageBox.Show("Transaction Amount must be a positive number.", "Checkbook")
End Try
That's my code so far. What am I doing wrong? Instead of using the actual field, do I need to store the number that was entered in a temp variable first? Examples always appreciated.
Thanks for your help!
Catch Err As Exception When (CInt(txtAmount.Text)) < 0
MessageBox.Show("Transaction Amount must be a positive number.", "Checkbook")
End Try
That's my code so far. What am I doing wrong? Instead of using the actual field, do I need to store the number that was entered in a temp variable first? Examples always appreciated.
Thanks for your help!