VB拆分字符串,估计要用到数值
将C9CACACACA239BCA23CA9B9B98CACA9BCA24拆分成C9CACACACA239BCA23CA9B9B98CACA9BCA24要求就是将所给的字...
将C9CACACACA23 9B CA23 CA9B 9B 98 CACA9B CA24
拆分成C9CA CACA CA23 9B CA23 CA9B 9B 98 CACA 9B CA24
要求就是将所给的字符串拆开,使每一块不多于四位
因为自己对数组不是很熟悉,暂时处理不了这个问题,希望各位帮忙解决一下,谢谢了 展开
拆分成C9CA CACA CA23 9B CA23 CA9B 9B 98 CACA 9B CA24
要求就是将所给的字符串拆开,使每一块不多于四位
因为自己对数组不是很熟悉,暂时处理不了这个问题,希望各位帮忙解决一下,谢谢了 展开
展开全部
最后的sp数组就是你要的
Option Explicit
Private Sub Command1_Click()
Dim sp() As String, str As String, st As String, t As Variant, i As Integer, c As Integer
i = 0
str = "C9CACACACA23 9B CA23 CA9B 9B 98 CACA9B CA24"
For Each t In Split(str, " ")
c = 1
st = Mid(CStr(t), c, 4)
While c + 4 < Len(CStr(t))
ReDim Preserve sp(i)
sp(i) = st
i = i + 1
c = c + 4
st = Mid(CStr(t), c, 4)
Wend
ReDim Preserve sp(i)
sp(i) = st
i = i + 1
Next
For Each t In sp
Print t
Next
End Sub
Option Explicit
Private Sub Command1_Click()
Dim sp() As String, str As String, st As String, t As Variant, i As Integer, c As Integer
i = 0
str = "C9CACACACA23 9B CA23 CA9B 9B 98 CACA9B CA24"
For Each t In Split(str, " ")
c = 1
st = Mid(CStr(t), c, 4)
While c + 4 < Len(CStr(t))
ReDim Preserve sp(i)
sp(i) = st
i = i + 1
c = c + 4
st = Mid(CStr(t), c, 4)
Wend
ReDim Preserve sp(i)
sp(i) = st
i = i + 1
Next
For Each t In sp
Print t
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询