|
-
Jun 22nd, 2004, 06:12 PM
#1
Thread Starter
Lively Member
Further Validation Help [Resolved]
I have been looking for syntax help with this:
Code:
If Val(TextBox1.Text) = (1,99) Then
TextBox2.Focus()
End If
I would like the the part in red to cause the focus to change when text box 1 value = any of the numbers from 1 to 99.
Thoughts.....
Last edited by teamdad; Jun 25th, 2004 at 08:49 PM.
-
Jun 22nd, 2004, 06:37 PM
#2
Member
From the top of my head, didn't check code, just typed it 
If InRange(Val(TextBox1.Text)) Then
TextBox2.Focus()
End If
function InRange(value as integer) as boolean
dim i as integer
for i = 1 to 99 do
if value = i then
InRange = true
exit function
end if
next
InRange = false
end function
If you can't find a standard function, make your own
-
Jun 22nd, 2004, 06:37 PM
#3
PowerPoster
Hi,
Hope this is not too simple:
VB Code:
If Val(TextBox1.Text) >=1 and val(TextBox1.Text)<=99 Then
TextBox2.Focus()
End If
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 22nd, 2004, 06:39 PM
#4
Member
D@mn I think too complicated 
If it works the same, always go for the solution with less code
-
Jun 22nd, 2004, 06:55 PM
#5
Thread Starter
Lively Member
It works great.... I don't know what I would ever do without the help I have gotten from this forum.
I just thought I had ran accross something somewhere with a format from my first post that validated a range of numbers.... maybe it was a range of letters?? Who knows what I think.
-
Jun 22nd, 2004, 07:15 PM
#6
PowerPoster
Originally posted by teamdad
It works great.... I don't know what I would ever do without the help I have gotten from this forum.
I just thought I had ran accross something somewhere with a format from my first post that validated a range of numbers.... maybe it was a range of letters?? Who knows what I think.
MSDN HELP does mention the use of ranges for all types except Boolean using the format 1 to 99, but I can't figure out how to use it
If you are going to check the entries in several textboxes and/or want to check against more than one range, then a slight amendment to cphoenixc's suggestion is appropriate:
VB Code:
If InRange(Val(TextBox1.Text), 1, 99) Then
TextBox2.Focus()
End If
function InRange(value1 as integer, range1 As Integer, Range2 As Integer) as boolean
If value1>=range1 and value1,=99 then
return True
Else
Return False
End If
End Sub
I altered "Value" to "Value1" because you should never use a key word as an integer name.
Last edited by taxes; Jun 22nd, 2004 at 07:30 PM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
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
|