VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



TO restrict the text box to numbers with single decimal point

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

Rate TO restrict the text box to numbers with single decimal point



    
    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



Download this snippet    Add to My Saved Code

TO restrict the text box to numbers with single decimal point Comments

No comments have been posted about TO restrict the text box to numbers with single decimal point. Why not be the first to post a comment about TO restrict the text box to numbers with single decimal point.

Post your comment

Subject:
Message:
0/1000 characters