VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Has... String Functions

by Jared Collums (3 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This is a series of Has.. Codes. It will search a textbox for the following: Lowercase letter, Uppercase letters, Numeric Characters, and Accented Characters. So, if it has lowercase letters or something, it will display a message box. this is a good example of how to use for..next loops, ASCII codes and the Instr Function, then again, this might be a lousy example, you be the judge.

Assumes
ASCII Codes, atleast add on to it, search for ASCII Gen and you will find one of my ASCII code generators.
Code Returns
Message Box if the Function returns true

Rate Has... String Functions

Public Function HasUppercase(TextBox As Object)
For i = 65 To 90 'i equals every letter from "A" to "Z"
If InStr(TextBox.Text, Chr$(i)) Then MsgBox "Has Uppercase"
'Searches for letters A to Z (i), and if i is present, Display a box.
End Function
Public Function HasLowercase(TextBox As Object)
For i = 97 To 122 'i equals every letter from "a" to "z"
If InStr(TextBox.Text, Chr$(i)) Then MsgBox "Has Lowercase"
'Searches for letters a to z (i), and if i is present, Display a box.
Next i
End Function
Public Function HasNumeric(TextBox As Object)
For i = 0 To 9 'i equals every number from "0" to "9"
If InStr(TextBox.Text, i) Then MsgBox "Has Numeric"
'Searches for numbers 0 to 9 (i), and if i is present, Display a box.
Next i
End Function
Public Function HasAccentchars(TextBox As Object)
For i = 128 To 223 'i equals every character from "€" to "ß"
If InStr(TextBox.Text, Chr$(i)) Then MsgBox "Has Accented Characters"
'Searches for accent characters € to ß (i), and if i is present, Display a box.
Next i
End Function

Download this snippet    Add to My Saved Code

Has... String Functions Comments

No comments have been posted about Has... String Functions. Why not be the first to post a comment about Has... String Functions.

Post your comment

Subject:
Message:
0/1000 characters