字符串a中的字段有一下3种形式的分隔:
(1)*****空格(N个)*****空格(N个))*****空格(N个)......
(2)*****tab*****tab*****tab......
(3)*****,*****,*****,......要求判断字符串中的字段是以什么字符间隔的,若是以空格间隔,还需要判断是几个空格一组来间隔的。请指教,谢谢!
(1)*****空格(N个)*****空格(N个))*****空格(N个)......
(2)*****tab*****tab*****tab......
(3)*****,*****,*****,......要求判断字符串中的字段是以什么字符间隔的,若是以空格间隔,还需要判断是几个空格一组来间隔的。请指教,谢谢!
Option ExplicitPrivate Sub Command1_Click()
Dim strP As strting
Dim intP As String
strP = "***** ***** *****"
intP = InStr(1, strP, " ", vbTextCompare)
If intP <> 0 Then Debug.Print "间隔是空格"
intP = InStr(1, strP, ",", vbTextCompare)
If intP <> 0 Then Debug.Print "间隔是逗号"
intP = InStr(1, strP, vbTab, vbTextCompare)
If intP <> 0 Then Debug.Print "间隔是制表符"
End Sub
If p2 Then
Do
n = n + 1
p1 = p2
p2 = Instr(p1, a, Space(1))
Loop While p2 = p1 + 1
End If
p2 = InStr(1, "abcf,defg", ",") p2=5InStr([start, ]string1, string2[, compare]) start咋不起作用呢?
n = n + 1
p1 = p2 + 1
p2 = Instr(p1, a, Space(1))
Loop While p2 = p1 + 1否则会找到同一个匹配。
Dim i%
Const s = "123 444 5655"
Do While Replace(s, Space(i + 1), "") <> s
i = i + 1
Loop
MsgBox i'这个i就是你要的空格数,会显示4
With CreateObject("vbscript.regExp")
.Pattern = "\s+"
MsgBox "空格长度是:" & Len(.Execute("123 444 5655")(0).Value)
End With
字符串“A空格Tab,B空格Tab,C”
是用什么字符间隔的?
(^_^)