|
-
Apr 19th, 2005, 07:48 PM
#1
Thread Starter
Lively Member
validation(resolved)
hi,
I want to do a validation on a textbox. it only accept numeric from -20 to 40.
below is part of my coding but i cant do the validation on the length and only accept -20 to 40. Please help.
Public Sub Val_Temp(TextObj As TextBox)
Dim i As Integer, n As Integer
Dim s As String, Char As Byte
i = TextObj.SelStart
For n = 1 To Len(TextObj)
Char = Asc(Mid(TextObj, n, 1))
If ((Char >= 48 And Char <= 57) Or (Char = 45 And n = 1) Then
s = s & Mid(TextObj, n, 1)
Else
i = i - 1
End If
Next n
If i > Len(s) Or i < 0 Then i = Len(s)
TextObj.Text = s
TextObj.SelStart = i
End Sub
Last edited by vivian2u; Apr 21st, 2005 at 11:33 AM.
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
|