VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A series of functions that aid client side validation for things like social security numbers. Only

by LockwoodTech (3 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Sat 29th July 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A series of functions that aid client side validation for things like social security numbers. Only valid keys will be allowed all others will

Rate A series of functions that aid client side validation for things like social security numbers. Only




Public Sub pub_Ascii_DateOnly(KeyAscii As Integer)
'Allows user to type in Date related chars only (i.e. "/", "#")
    If KeyAscii = 8 Then
        Exit Sub 'Do nothing for backspace
    ElseIf KeyAscii < 47 Or KeyAscii > 59 Then
        'Limit characters to numeric and back-slash only
        KeyAscii = 0
        Exit Sub
    End If
End Sub

Public Sub pub_Ascii_Delete(KeyCode As Integer, Shift As Integer)
'   Deletes SELECTed item on a listbox when user hits [Delete] on keyboard
    'If KeyCode = 46 Then Call pub_Delete
End Sub

Public Sub pub_Ascii_NoQuotes(KeyAscii As Integer)
'   No quotation marks or Returns
'   Limits what users can type into a multi-line text box
'   Quotes are converted to apostrophes
    If KeyAscii = 34 Then
        KeyAscii = 0
        KeyAscii = 39
        'Screen.ActiveControl = Screen.ActiveControl.Text & "''"
    End If
End Sub

Public Sub pub_Ascii_Tab(KeyAscii As Integer)
    If KeyAscii = 13 Then
        'Tab for enter key
        KeyAscii = 0
        SendKeys "{Tab}"
    End If
End Sub

Public Sub pub_Ascii_NumOnly(KeyAscii As Integer)
    If KeyAscii = 8 Or KeyAscii = 46 Or KeyAscii = 13 Then
        'Do nothing for backspace(8) or period(46) or enter(13)
    ElseIf KeyAscii < 48 Or KeyAscii > 59 Then
        'Limit characters to numeric only
        KeyAscii = 0
    End If
End Sub

Public Sub pub_Ascii_SSN(KeyAscii As Integer)
    If KeyAscii = 8 Or KeyAscii = 45 Then
        'Do nothing for backspace(8) or "-"
    ElseIf KeyAscii < 48 Or KeyAscii > 59 Then
        'Limit characters to numeric only
        KeyAscii = 0
    End If
End Sub

Public Sub pub_Ascii_NumOnlyAndTab(KeyAscii As Integer)
    If KeyAscii = 8 Or KeyAscii = 46 Or KeyAscii = 13 Then
        'Do nothing for backspace(8) or period(46) or enter(13)
    ElseIf KeyAscii = 13 Then
        'Tab for enter key
        KeyAscii = 0
        SendKeys "{Tab}"
    ElseIf KeyAscii < 48 Or KeyAscii > 59 Then
        'Limit characters to numeric only
        KeyAscii = 0
    End If
End Sub

Download this snippet    Add to My Saved Code

A series of functions that aid client side validation for things like social security numbers. Only Comments

No comments have been posted about A series of functions that aid client side validation for things like social security numbers. Only. Why not be the first to post a comment about A series of functions that aid client side validation for things like social security numbers. Only.

Post your comment

Subject:
Message:
0/1000 characters