SteveOOOsw
n00b
- Joined
- Dec 3, 2005
- Messages
- 19
How would one verify that data is entered into a textbox and if not the method is aborted?
Here is what I am having problems with...
The following will display the error message but not abort the method
Or throwing a custom exception will display the error message and abort the method but it will also display an unhanded exception message
Here is what I am having problems with...
The following will display the error message but not abort the method
Code:
If (UserNameTextBox.Text.Length = 0) Then
MessageBox.Show("User name is required.")
Else
strUserName = UserNameTextBox.Text
End If
Or throwing a custom exception will display the error message and abort the method but it will also display an unhanded exception message
Code:
If (UserNameTextBox.Text.Length = 0) Then
Throw New RequiredFieldException("User name is required.")
Else
strUserName = UserNameTextBox.Text
End If