VB RichTextBox 如何查找文本个数

来源:百度知道 编辑:UC知道 时间:2024/09/26 03:23:43
不是查找 是查找个数
比如RichTextBox.text="111222333222"
"2"在里面存在6个 这样返回 就可以了

Private Sub FormatCode(ByVal vstrKey As String) 这是一个搜索的子过程
Dim lngCodeLen As Long
Dim lngPlace As Long, lngVbcrlf As Long
Dim lngKeyCount As Long
static t as integer
lngKeyCount = Len(vstrKey)
lngCodeLen = LenB(RichTextBox1.Text)

RichTextBox1.SelStart = 0
Do While lngPlace <> -1
With RichTextBox1
lngPlace = .Find(vstrKey, , lngCodeLen)
If lngPlace <> -1 Then
t=t+1
.SelColor = vbBlue
.SelStart = lngPlace + lngKeyCount
End If
End With
Loop
End Sub

Private Sub Command1_Click()
FormatCode("你搜索内容")
Print "出现的次数" & t
End Sub

dim i , x ,y
for i = len(111222333222)
if x = "2" then
y = y + 1
end if
next

Private Sub Command1_Click()
For i = 1 To Len(Text1.Text)
x = Mid("111222333222", i, 1)
If x = "2" Then