Apprentice
July 16th, 2001, 05:16 PM
I have an array of four TextBoxes. I made them an array so that I could reduce my code by writing the Validation event sub function only once. Unfortunately, VB seems to insist that I specify a single member of the array for my validation code. If I have to do that, then I'll wind up writing the code four times anyway so what's the point? I'm thinking that there has got to be some way to indicate that the index of the control doesn't matter. Anyway, here's my code so far:
private Sub txtXY_Validate(Index as Integer, KeepFocus as Boolean)
If Not IsNumeric(txtXY(0).Text) Or Val(txtXY(0).Text) < -250 Or Val(txtXY(0).Text) > 250 then
KeepFocus = true
Call MsgBox("Please enter a number between -250 and 250, inclusive.", , "Line Generator")
End If
End Sub
I would like to avoid writing that If...Then statement three more times, if possible.
Thanks for any help, and feel free to ask for clarification.
The more you know, the more you know you don't know.
private Sub txtXY_Validate(Index as Integer, KeepFocus as Boolean)
If Not IsNumeric(txtXY(0).Text) Or Val(txtXY(0).Text) < -250 Or Val(txtXY(0).Text) > 250 then
KeepFocus = true
Call MsgBox("Please enter a number between -250 and 250, inclusive.", , "Line Generator")
End If
End Sub
I would like to avoid writing that If...Then statement three more times, if possible.
Thanks for any help, and feel free to ask for clarification.
The more you know, the more you know you don't know.