|
-
July 16th, 2001, 05:16 PM
#1
TextBox Array
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.
The more you know, the more you know you don't know.
-
July 16th, 2001, 06:31 PM
#2
Re: TextBox Array
(Index as Integer) specifies which of the Textboxes you are working with so replace
If Not IsNumeric(txtXY(0).Text) Or Val(txtXY(0).Text) < -250 Or Val(txtXY(0).Text) > 250 then
'
' with
If Not IsNumeric(txtXY(Index).Text) Or Val(txtXY(Index).Text) < -250 Or Val(txtXY(Index).Text) > 250 then
This will then cause your code to be working with whatever textbox the user is playing with.
John G
-
July 16th, 2001, 06:38 PM
#3
Thank you!
That's just what I needed. What a relief. I knew there had to be a simple solution.
The more you know, the more you know you don't know.
The more you know, the more you know you don't know.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|