vb文本框数组分解的所有组合
文本框1有如下数组:12578111223679101545610131719等数组,每组7个数,数与数之间有一个空格,怎么用一个按钮就把上面所有数组,按5个数一组的所有...
文本框1有如下数组:
1 2 5 7 8 11 12
2 3 6 7 9 10 15
4 5 6 10 13 17 19等数组,每组7个数,数与数之间有一个空格,怎么用一个按钮就把上面所有数组,按5个数一组的所有组合显示到text2呢?上面三组7个数的组合可分解成63组5个数一组的所有组合。如text2这样显示:
2 3 6 7 9
2 3 6 7 10
2 7 9 10 15
4 10 13 17 19
2 6 7 9 10等等数组,数与数之间有一个空格,感谢老师能帮我解开这个谜团!!! 展开
1 2 5 7 8 11 12
2 3 6 7 9 10 15
4 5 6 10 13 17 19等数组,每组7个数,数与数之间有一个空格,怎么用一个按钮就把上面所有数组,按5个数一组的所有组合显示到text2呢?上面三组7个数的组合可分解成63组5个数一组的所有组合。如text2这样显示:
2 3 6 7 9
2 3 6 7 10
2 7 9 10 15
4 10 13 17 19
2 6 7 9 10等等数组,数与数之间有一个空格,感谢老师能帮我解开这个谜团!!! 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim s() As String, i As Long, t() As String
Dim n1 As Integer, n2 As Integer, n3 As Integer, n4 As Integer, n5 As Integer
Text2.Text = ""
s = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(s)
t = Split(s(i), " ")
If UBound(t) = 6 Then
For n1 = 0 To 2
For n2 = n1 + 1 To 3
For n3 = n2 + 1 To 4
For n4 = n3 + 1 To 5
For n5 = n4 + 1 To 6
Text2.Text = Text2.Text & t(n1) & " " & t(n2) & " " & t(n3) & " " & t(n4) & " " & t(n5) & vbCrLf
Next
Next
Next
Next
Next
End If
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询