
vb查找文本重复次数
比如说我在有个按钮Command1和文框text1,还有一个标签Label1,我点击按钮然后查找重复了几次,然后以数字的形式写在label1中...
比如说我在有个按钮Command1和文框text1,还有一个标签Label1,我点击按钮然后查找重复了几次,然后以数字的形式写在label1中
展开
4个回答
展开全部
Private Sub Command1_Click()
Dim cz$
cz = InputBox("要查找什么")
Label1.Caption = (Len(Text1.Text) - Len(Replace(Text1.Text, cz, ""))) / Len(cz)
End Sub
Dim cz$
cz = InputBox("要查找什么")
Label1.Caption = (Len(Text1.Text) - Len(Replace(Text1.Text, cz, ""))) / Len(cz)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim i As Integer
Dim sum As Integer
Dim str As String
str = InputBox("要查找什么")
i = 1
Do While i < Len(Text1.Text)
i = InStr(i, Text1.Text, str, vbTextCompare)
If i > 0 Then sum = sum + 1: i = i + Len(str) Else Exit Do
Loop
Label1.Caption = sum
End Sub
Dim i As Integer
Dim sum As Integer
Dim str As String
str = InputBox("要查找什么")
i = 1
Do While i < Len(Text1.Text)
i = InStr(i, Text1.Text, str, vbTextCompare)
If i > 0 Then sum = sum + 1: i = i + Len(str) Else Exit Do
Loop
Label1.Caption = sum
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要在label1上显示你查找的次数?把下面代码粘贴到按钮单击事件中就可以了
Private Sub Command1_Click()
Static a As Integer
a = a + 1
Label1.Caption = "你当前查到了" & a & "次"
End Sub
Private Sub Command1_Click()
Static a As Integer
a = a + 1
Label1.Caption = "你当前查到了" & a & "次"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-02-17
展开全部
是查找“字”重复还是“句”重复?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询