VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Match() Check any string for any number of characters.

by Matthew Roberts (26 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

Simple function to validate string contents. Compares a given string to a list of illegal values and evaluates whether or not it contains any. Very fast and easy. Can also be used as a string search function with a little modification.

Inputs
strSource - String you are checking strCompare - String of illegal characters
Assumes
To run: If Match (strMyFile, "~!@#$%^&*()+`{}[]?><,/") Then MsgBox "File contains illegal characters!", vbExclaimation End If .
Code Returns
Boolean - True = Source string contains an illegal character.

Rate Match() Check any string for any number of characters.


Public Function Match(strSource As String, strCompare As String) As Boolean
Dim lngCheck As Long
 
 For lngCheck = 1 To Len(strCompare)
 If InStr(strSource, Mid(strCompare, lngCheck, 1)) Then
 Match = True
 Exit Function
 End If
 
 Next lngCheck
End Function

Download this snippet    Add to My Saved Code

Match() Check any string for any number of characters. Comments

No comments have been posted about Match() Check any string for any number of characters.. Why not be the first to post a comment about Match() Check any string for any number of characters..

Post your comment

Subject:
Message:
0/1000 characters