Hi there. I am currently developing a small application to tell users what grade of security their password has. Now, to do this, i need to check what the textbox contains, like signs, numbers, how many lines they are and so on. I can understand the basic syntax for it:
If Textbox1 = contains !"# %&/()= then metervalue = metervalue + 5
Well, that is what i have figured out, but i don't know the proper command to see if a textbox contains something. I know how to check if the content matches a word or a number, but i don't know how to check if the textbox contains letters, how many they are and so on. If anyone can help me on this, would it be extremely appreciated.

Finding out what a textbox contains
TheFoZ
Public
Class Form1Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Strings.InStr(TextBox1.Text, "dog").CompareTo(0) Then MessageBox.Show("dog") Else MessageBox.Show("no dog")
If Strings.InStr(TextBox1.Text, "cat").CompareTo(0) Then MessageBox.Show("cat") Else MessageBox.Show("no cat")
If Strings.InStr(TextBox1.Text, "fish").CompareTo(0) Then MessageBox.Show("fish") Else MessageBox.Show("no fish")
End Sub
End Class
A Hell of a lot Less Pasta (spaghetti) way More Sauce (OPP),,,, The Atkin's Way(OPP Way).... I'm starting to Get It..........
Ishaq
There's another way to do it.....
Private Sub Textbox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim ForbiddenChars As String = "!@#$%^&*()_+"
If ForbiddenChars.Contains(e.KeyChar) Then
'do stuff
Else
'do other stuff
e.Handled = True
End If
End Sub
Curtis_more
'-------------------------------------------------------------------------------------
Dim charArray(3), character As Char
charArray(0) = "!"
charArray(1) = "#"
charArray(2) = "$"
For Each character In charArray
If InStr(TextBox1.Text, character) > 0 Then
MessageBox.Show("There is a special character in the password")
End If
Next
'-------------------------------------------------------------------------------------
I'm positive that this is not the best way, but it works.
I would say there's probably some way you could figure out a range of ASCII values for special characters and then loop through the string.tochararray array, but you would have to look into that.
Moishe
Public
Class Form1 Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickMsgBox(TextBox1.Text)
End SubEnd
ClassMohamed B.
cprcrack
Battula
hi,
you can get every letter in the textbox and put it in array and loop through it and to know if its letter or number, i hope if you give a concrete example
Private
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickMessageBox.Show(
"how many letters in the textbox = " + TextBox1.Text.Length.ToString()) Dim textboxletters() As Char Dim singleletter As Chartextboxletters = TextBox1.Text.ToCharArray()
For Each singleletter In textboxletters If IsNumeric(singleletter) ThenMessageBox.Show(
"I found a number = " + singleletter) ElseMessageBox.Show(
"I found a letter (" + singleletter + ")") End If
Next End Subhope that helps
LesSmith