指定字符在字符串中的个数以及位置数值
现在串口返回这样一组字符串“1,1,1,1,0,1,0,0,1,0,1,1,0,1,1”请问用什么函数来求字符“0”在此字符串中的个数以及出现的位置数值。 不吝赐教!
Dim ss As String = "1,1,1,1,0,1,0,0,1,0,1,1,0,1,1" Dim ii As Integer = 0 For i As Integer = 0 To ss.Replace(",", "").Length - 1 If ss.Replace(",", "").Substring(i, 1) = "0" Then ii += 1 MsgBox("第" & i + 1 & "位是个0") End If Next MsgBox("一共有" & ii & "个0")