vb文本框数组排列问题
文本框有多组数据如:1234567,1569101113等数组数据,数与数之间有一个空格,怎么实现用一个按纽就把这些数组数据按5个数一组的所有组合显示到另一个文本框,如1...
文本框有多组数据如:1 2 3 4 5 6 7,1 5 6 9 10 11 13等数组数据,数与数之间有一个空格,怎么实现用一个按纽就把这些数组数据按5个数一组的所有组合显示到另一个文本框,如1 2 3 4 5,1 2 3 4 6,1 2 3 4 7等等,数与数之间有空格,感谢!!!
展开
1个回答
展开全部
‘可能实现的方法很多,我只会这一种,希望对你有帮助。关键代码如下:
Dim S As String
S = "1 2 3 4 5 6 7,1 5 6 9 10 11 13"
S = Replace(S, ",", " ")
Dim ShuZi() As String
ShuZi = Split(S, " ") '将带空格的数字串打散为数组
Dim S1 As String
S1 = ""
For i = 0 To UBound(ShuZi)
If S1 = "" Then
S1 = ShuZi(0)
Else
If i Mod 5 = 0 Then ‘每间隔5位
S1 = S1 & "," & ShuZi(i)
Else
S1 = S1 & Space(1) & ShuZi(i)
End If
End If
Next
MsgBox (S1)
Dim S As String
S = "1 2 3 4 5 6 7,1 5 6 9 10 11 13"
S = Replace(S, ",", " ")
Dim ShuZi() As String
ShuZi = Split(S, " ") '将带空格的数字串打散为数组
Dim S1 As String
S1 = ""
For i = 0 To UBound(ShuZi)
If S1 = "" Then
S1 = ShuZi(0)
Else
If i Mod 5 = 0 Then ‘每间隔5位
S1 = S1 & "," & ShuZi(i)
Else
S1 = S1 & Space(1) & ShuZi(i)
End If
End If
Next
MsgBox (S1)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询