遍历字符串,每次遍历到字符"7",就在初始值为0的变量i+1以下是代码Module Module1
Sub Main()
Dim strA As String = "777787778967"
Dim i As Integer = 0
For Each strB As String In strA
If strB = "7" Then
i = i + 1
End If
Next
Console.WriteLine("字符串777787778967中共有{0}个7.", i.To...
Private Sub Form_load() Dim a, b As String Dim i, n As Integer a = "777787778967": b = "7" On Error Resume Next For i = 1 To Len(a) If Mid(a, i, Len(b)) = b Then n = n + 1 Next i M...
Dim A As String, B As StringDim N As Integer, iPos As IntegerA = "777787778967"B = "7"Do
iPos = InStr(iPos + 1, A, B)
If iPos = 0 Then Exit Do
N = N + 1 ...