随机8组进行排列组合(不重复),输出到文本框2
取文本框1(multiline=true)内容如下:
aa,
56bc,
120qdf,
取而非,
foee.,
tom,
best,
7900,
5#额,
36hgfh,
ewfw,
bbbb,
38fe,
fwef45666,
rfgerg,
随机取8个排列组合10组.输出到文本框2
如图:
http://hiphotos.baidu.com/%CC%EC%B7%E7%BA%A3%CB%AE/pic/item/f52eb91817e5880635fa41be.jpg
谢谢.
[370 byte] By [
yj20068] at [2008-1-9]
Private Sub Form_Load()
Dim temp() As String
Dim Num(7) As Long
Dim m As Long, n As Long, ret As Long, x As Long
Dim Str As String
temp = Split(Text1.Text, vbCrLf)
m = UBound(temp)
If temp(m) = "" Then ReDim Preserve temp(m - 1) As String
Randomize Timer
For x = 1 To 10
Str = ""
For n = 0 To 7
DoNext:
m = Int(Rnd * UBound(temp))
For ret = 0 To n
If Num(ret) = m Then GoTo DoNext
Next ret
Num(n) = m
Str = Str & temp(m)
Next n
Debug.Print Str
Next x
End Sub
你好,这个问题是怎么输出10组到文本框2.
你能再帮我看看吗?
谢谢
第1组
38fe,fwef45666-rfgerg,36hgfh,7900,foee.,取而非,best,5#额,
第2组
省略
第3组
省略
第4组
省略
第5组
省略
第6组
省略
第7组
省略
第8组
省略
第9组
省略
第10组
省略
Private Sub Form_Load()
Dim temp() As String
Dim Num(7) As Long
Dim m As Long, n As Long, ret As Long, x As Long
Dim Str As String
temp = Split(Text1.Text, vbCrLf)
m = UBound(temp)
If temp(m) = "" Then ReDim Preserve temp(m - 1) As String
Randomize Timer
For x = 1 To 10
Str = Str & "第" & x & "组" & vbCrLf
For n = 0 To 7
DoNext:
m = Int(Rnd * UBound(temp))
For ret = 0 To n
If Num(ret) = m Then GoTo DoNext
Next ret
Num(n) = m
Str = Str & temp(m)
Next n
Str = Str & vbCrLf
Next x
Debug.Print Str
text2.Text = Str
End Sub