Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 192
Viewed: 2881
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 - 2017 snippetlibrary.com All Rights Reserved. Conditions