0

Hi,

I'm manage how to find word in textbox.
In textbox : "How i can be a good programer? How i achieve that?"
If i want to search "How" then it should return 2 How words in text.

Please Help.
Thank You.

3
Contributors
6
Replies
12
Views
6 Years
Discussion Span
Last Post by Basavaraj16291
0

This what i have so far :

Dim str As String
Dim i, temp, Count As Integer
Count = 0

While temp > 0
    temp = InStr(1, Text1.Text, "How")
    Count = Count + 1
Wend
MsgBox Count

But the result is wrong.

Edited by dnk: n/a

2

See if this helps :

Dim i, Count As Integer

Count = 0

i = InStr(i + 1, Text1.Text, "How")
If i = 0 Then
    MsgBox 0
    Exit Sub
End If

Do While i > 0
    i = InStr(i + 1, Text1.Text, "How")
    Count = Count + 1
Loop

MsgBox Count
Votes + Comments
Nice code
Thanks
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.