Growler
Member
- Joined
- Sep 23, 2010
- Messages
- 13
- Programming Experience
- Beginner
Part of my assignment is to check if input to Group Number and Number of Units are correct input by making error handling exceptions...
I have to check the following:
a) group number is neither 501 nor 062
b) number of units are NOT numbers
c) number of units is NOT a positive number
So my first question is, am I checking correctly?
2nd question is, How do I make sure my Exceptions will pertain to their correct respective things (a, b, and c.. above)?
Thanks!
I have to check the following:
a) group number is neither 501 nor 062
b) number of units are NOT numbers
c) number of units is NOT a positive number
So my first question is, am I checking correctly?
2nd question is, How do I make sure my Exceptions will pertain to their correct respective things (a, b, and c.. above)?
Thanks!
VB.NET:
Try
Dim txtGroupNum(Not "501" Or "062")
Dim txtUnits As Integer
Dim txtUnits < 0
Catch ex As Exception
MessageBox.Show("Please enter either Group 501 or 062", "Group number error")
Catch ex As InvalidCastException
MessageBox.Show("Please enter a number", "Invalid input!")
Catch ex As InvalidOperationException
MessageBox.Show("Please enter a positive number", "Invalid input!")