Click to See Complete Forum and Search --> : error checking


bentley
October 30th, 2002, 08:37 PM
ok i have the following line of code

Do While intBase < 2 Or intBase > 9

MsgBox("Error, Try Again")

intBase = txtBase.Text

Loop

i can seem to get the program to pause and let the user enter another set of data. can anyone help me out with my problem?

Athley
October 31st, 2002, 01:48 AM
Well your code might work if you find a user that i fast enough to change the value of the textbox before the loop gets back to that msgbox. :)

Just kidding.

Is it possible for you to code this on any Event? For example the Changed event or the Validating event?

/Leyan

bentley
October 31st, 2002, 09:33 AM
i just want the user to enter the new data. I just dont know how to do that. To get the program to actually let the user enter the data and pause. Any suggestions?

Athley
October 31st, 2002, 11:18 AM
I'm not sure about what you mean, but if you use a code similar to the one below you will prompt the user when the textbox gets validated.

Private Sub TextBox1_Validating(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If IsNumeric(TextBox1.Text) Then
If CInt(TextBox1.Text) < 2 Or CInt(TextBox1.Text) > 9 Then
MsgBox("Eyyy, wrong number!")
End If
End If
End Sub


/Leyan