|
-
Jan 4th, 2000, 06:56 AM
#1
Thread Starter
Member
HI.
Ok let's say i have the textbox and my code is:
Code:
Private Sub txt1_KeyPress(KeyAscii As Integer)
If KeyAscii > 57 Or KeyAscii = 32 Or KeyAscii = 33 Or KeyAscii = 35 Or KeyAscii = 36 Or KeyAscii = 37 Or KeyAscii = 38 Or KeyAscii = 40 Or KeyAscii = 41 Or KeyAscii = 42 Or KeyAscii = 43 Or KeyAscii = 44 Or KeyAscii = 45 Or KeyAscii = 47 Then
KeyAscii = 0
End If
End Sub
This code prevents text writing in the textbox.
And the question Is: How can i prevent
writing of second dot?
for egzample 2.1133...
or 654.15.
-
Jan 4th, 2000, 07:40 AM
#2
Use the InStrRev function and search for
a "." in the text.
-
Jan 4th, 2000, 07:49 AM
#3
Member
Private Sub txt1_KeyPress(KeyAscii As Integer)
' Allow only "(34), '(39), .(46), 0~9(48~57)
' I also allow "Backspace"(8)
If KeyAscii <> 34 And KeyAscii <> 39 And KeyAscii <> 46 _
And KeyAscii <> 8 And Not (KeyAscii > 47 And KeyAscii < 58) Then
KeyAscii = 0
ElseIf KeyAscii = 46 Then
If InStr(1, txt1, ".") > 0 Then KeyAscii = 0
End If
End Sub
HTH
Joon
-
Jan 4th, 2000, 07:10 PM
#4
Thread Starter
Member
That's a bit complicated but i'll try to understand
thanx
-casparas
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
|