2 Methods:
Both Require 2 Textboxes and a Command Button..
1. Use the Replace Function in VB6..
Code:
Private Sub Command1_Click()
Dim iNum As Long
iNum = Len(Text1)
iNum = (iNum - Len(Replace(LCase(Text1), LCase(Text2), ""))) / Len(Text2)
MsgBox "The String: " & Chr(34) & Text2 & Chr(34) & " Appears in the Text " & iNum & " Times."
End Sub
2. Use the Instr Function..
Code:
Private Sub Command1_Click()
Dim iNum As Long
Dim iPos As Integer
Do
iPos = InStr(iPos + 1, LCase(Text1), LCase(Text2))
If iPos Then iNum = iNum + 1
Loop While iPos
MsgBox "The String: " & Chr(34) & Text2 & Chr(34) & " Appears in the Text " & iNum & " Times."
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]