vb.net中求字符串2在字符串1中出现的所有位置以及出现次数
1个回答
2008-03-28
展开全部
Dim str1 As String = "112113114111"
Dim str2 As String = "11"
Dim count As Integer = 0
For i As Integer = 0 To str1.Length - 1
Dim f As Integer = str1.IndexOf(str2, i)
If f > -1 Then
MsgBox("str2出现在str1的" & f & "个字符位慧乱置")
i = f
count += 1
End If
Next
MsgBox("统计前睁档出str1中共有早判" & count & "个str2!")
Dim str2 As String = "11"
Dim count As Integer = 0
For i As Integer = 0 To str1.Length - 1
Dim f As Integer = str1.IndexOf(str2, i)
If f > -1 Then
MsgBox("str2出现在str1的" & f & "个字符位慧乱置")
i = f
count += 1
End If
Next
MsgBox("统计前睁档出str1中共有早判" & count & "个str2!")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询