vb 排列组合问题
文本框1-5为第一组文本框6-10为第二组.列举出第一组和第二组中字符的排列组合.实际应用的时候第一组和第二组中文本框的数量可能是5~10个如图...
文本框1-5为第一组
文本框6-10为第二组.
列举出第一组和第二组中字符的排列组合.
实际应用的时候第一组和第二组中文本框的数量可能是5~10个
如图
展开
展开全部
Sub CreateCombination(Byval n1 As Integer, Byval n2 As Integer)
Dim i As Integer
Dim j As Integer
Dim s As String
n1 = n1 - 1
n2 = n2 - 1
ReDim s1(0 To n1) As String
ReDim s2(0 To n2) As String
For i = 0 To n1
s1(i) = Text1(i).Text
Next i
For i = 0 To n2
s2(i) = Text2(i).Text
Next i
For i = 0 To n1
For j = 0 To n2
s = s & s1(i) & vbCrLf
s = s & s2(j) & vbCrLf
s = s & "-----" & vbCrLf
Next j
Next i
TextResult.Text = s
End Sub
调用就可以了
Private Sub Command1_Click()
'第一组5个,第二组5个
CreateCombination 5, 5
'第一组5个,第二组10个
CreateCombination 5, 10
End Sub
Dim i As Integer
Dim j As Integer
Dim s As String
n1 = n1 - 1
n2 = n2 - 1
ReDim s1(0 To n1) As String
ReDim s2(0 To n2) As String
For i = 0 To n1
s1(i) = Text1(i).Text
Next i
For i = 0 To n2
s2(i) = Text2(i).Text
Next i
For i = 0 To n1
For j = 0 To n2
s = s & s1(i) & vbCrLf
s = s & s2(j) & vbCrLf
s = s & "-----" & vbCrLf
Next j
Next i
TextResult.Text = s
End Sub
调用就可以了
Private Sub Command1_Click()
'第一组5个,第二组5个
CreateCombination 5, 5
'第一组5个,第二组10个
CreateCombination 5, 10
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询