Not a Member Yet,
Click here to Register

ID: 192
Viewed: 3541
Added: Apr 29, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Check for valid input in text box

Highlight all by clicking in box
<!---Declaration--->
'Put this subroutine in BAS module
Public Function ValidChar(InSearch As String, InCriteria As String) As Boolean
'Purpose: Check for valid input
'Input: String from text box, Criteria string
'Output: True or False

Dim SearchCtr As Integer
Dim SearchLen As Integer
SearchLen = Len(Trim(InSearch))

' if nothing to search for, leave and say its okay
If (SearchLen = 0) Then
ValidChar = True
Exit Function
End If

' test each character
For SearchCtr = 1 To SearchLen
If InStr(1, InCriteria, Mid(InSearch, SearchCtr, 1), 1) = 0 Then
' it fails, exit now
ValidChar = False
Exit Function
End If
Next
ValidChar = True
End Function

Highlight All
<!---Code--->
'Put this code in text box
If Len(txtText) > 0 Then
'Exit if other than numeric data entered
If ValidChar(txtText.Text, "0123456789") = False Then
MsgBox "Please enter whole numbers only" + vbCrLf + "No leading spaces allowed", vbExclamation + vbOKOnly, "Validation Error"
txtText.SetFocus
Exit Sub
End If
End If
;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!