[Help] Checking a textbox for a word [solved]

Posts 14 of 4 · Page 1 of 1
[Help] Checking a textbox for a word [solved]
how can i check if textbox contains f.e. "$" more than one time
i already tried
Code:
Dim S As String = "$"
For Each S In TextBox1.Text
Msgbox("..")
Next
Here:

Code:
Dim WordCount As Integer = 0
        For i = 1 To TextBox1.Text.Length
            If Mid(TextBox1.Text, i, 1) = "$" Then
                WordCount += 1
            End If
        Next
        MsgBox(WordCount)
Quote Originally Posted by Lyoto Machida View Post
Here:

Code:
Dim WordCount As Integer = 0
        For i = 1 To TextBox1.Text.Length
            If Mid(TextBox1.Text, i, 1) = "$" Then
                WordCount += 1
            End If
        Next
        MsgBox(WordCount)
solved thanks
going to check mid function moar


[highlight=vb.net]
Private Function getWordCount(ByVal searchStr as string, byval targetstring as string) as integer
Return System.Text.RegularExpressions.Regex.Matches(targe tstring, System.Text.RegularExpressions.Regex.Escape(search Str)).Count
End Function
[/highlight]

Gotta love RegEx.
Posts 14 of 4 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Need help?