vb 字符串拆分
如何把以下字符串:农药2000化肥500花粉500拆分成:农药2000化肥500花粉500...
如何把以下字符串: 农药2000化肥500花粉500
拆分成 :
农药2000
化肥500
花粉500 展开
拆分成 :
农药2000
化肥500
花粉500 展开
展开全部
s = "农药2000化肥500花粉500"
n = 1
For I = 1 To Len(s)
If IsNumeric(Mid(s, I, 1)) Then
For j = I To Len(s)
If Not IsNumeric(Mid(s, j, 1)) Then
s1 = s1 & Mid(s, n, j - n) & vbCrLf
n = j
I = j
Exit For
End If
If j >= Len(s) Then
s1 = s1 & Mid(s, n)
I = j
End If
Next
End If
Next
MsgBox s1
追问
当:s = "2000农药500化肥500花粉"
又怎么样拆分成:
农药2000
化肥500
花粉500
追答
s = "2000农药500化肥500花粉"
n = 1
For I = 1 To Len(s)
If Not IsNumeric(Mid(s, I, 1)) Then
For j = I To Len(s)
If IsNumeric(Mid(s, j, 1)) Then
s1 = s1 & Mid(s, I, j - I) & Mid(s, n, I - n) & vbCrLf
n = j
I = j
Exit For
End If
If j >= Len(s) Then
s1 = s1 & Mid(s, I) & Mid(s, n, I - n)
I = j
End If
Next
End If
Next
MsgBox s1
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询