VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



VALIDATES DATA ENTRY IN TEXT BOXES CRITICAL IN BUSINESS ENVIRONMENT

by Kiran (3 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 22nd May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

VALIDATES DATA ENTRY IN TEXT BOXES CRITICAL IN BUSINESS ENVIRONMENT

Rate VALIDATES DATA ENTRY IN TEXT BOXES CRITICAL IN BUSINESS ENVIRONMENT




Private Sub text1_KeyPress(KeyAscii As Integer)
 
If KeyAscii = 46 Then

KeyAscii = 0
    
End If
  
If Chr(KeyAscii) Like "#" <> True And KeyAscii <> vbKeyBack And KeyAscii <>  vbKeyDelete Then
   
KeyAscii = 0
   
End If

End Sub

'* The following code allows only numbers and letters

Private Sub text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 46 Then
  
KeyAscii = 0
Exit Sub
    
End If
  
If ((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 90) Or (KeyAscii >= 97 And KeyAscii <= 122) Or (KeyAscii = vbKeyDelete) Or (KeyAscii = vbKeyBack)) <> True Then
   
KeyAscii = 0
   
End If

End Sub

'* The following code allows only alphabets

Private Sub text1_KeyPress( KeyAscii As Integer)

If KeyAscii = 46 Then
      
KeyAscii = 0
Exit Sub
        
End If

If Chr(KeyAscii) Like "[a-zA-Z]" <> True And KeyAscii <> vbKeyBack And KeyAscii <> vbKeySpace And KeyAscii <> vbKeyDelete Then
       
KeyAscii = 0
       
End If

end sub    

'* The following code allows only numbers and "-"

private sub text1_keypress(keyascii as integer)    
    
If KeyAscii = 46 Then
        
KeyAscii = 0
Exit Sub
        
End If
      
If Chr(KeyAscii) Like "#" <> True And KeyAscii <> Asc("-") And KeyAscii <> vbKeyBack And KeyAscii <> vbKeyDelete And KeyAscii <> vbKeySpace Then
       
KeyAscii = 0
       
End If
    
End Sub

'* The following code allows only one decimal point

Private Sub text1_KeyPress(KeyAscii As Integer)
  
Static dotentered As Boolean

If InStr(txtper, ".") > 0 Then
    
dotentered = True

Else

dotentered = False

End If
  
If KeyAscii = 46 And dotentered Then

KeyAscii = 0
Exit Sub

End If
  
If Chr(KeyAscii) Like "#" <> True And KeyAscii <> vbKeyBack And KeyAscii <> vbKeyDelete Then
    
keyAscii = 0
    
End If

End Sub




Download this snippet    Add to My Saved Code

VALIDATES DATA ENTRY IN TEXT BOXES CRITICAL IN BUSINESS ENVIRONMENT Comments

No comments have been posted about VALIDATES DATA ENTRY IN TEXT BOXES CRITICAL IN BUSINESS ENVIRONMENT. Why not be the first to post a comment about VALIDATES DATA ENTRY IN TEXT BOXES CRITICAL IN BUSINESS ENVIRONMENT.

Post your comment

Subject:
Message:
0/1000 characters