by Paresh Khond (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 1st June 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
TO restrict the text box to numbers with single decimal point
API Declarations
dim f,j as integer
If Len(Trim(Text1)) = 0 Then
f = 0
End If
For j = 1 To Len(Trim(Text1))
d = Mid(Text1, j, 1)
If d = "." Then
f = f + 1
Exit For
Else
f = 0
End If
Next
If Chr(KeyAscii) = vbBack Then Exit Sub
If KeyAscii = 46 And f = 0 Then Exit Sub
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
KeyAscii = 0
End If
End sub