作者nathanwu (孤苦无依肥胖烟酒生)
看板Visual_Basic
标题[VB6 ]请问指派问题
时间Tue Nov 22 22:02:37 2005
指派问题
作者: N (---.ie.nthu.edu.tw)
日期: 11-22-05 21:01
请问如果今天我将1~n的数字以四个一组
列出所有的组合出来
然後指派一组数字後
让未被指派的数字再去计算并列出所有的组合出来
然後继续指派下去直到所有数字都被指派完毕
我是已经将组合的程式写出如下
但是没办法做二次选取
能否请各位大大指教一下
感激不尽
Private Sub runCmd_Click()
Cls
nob = Val(nob.Text)
'---generate data and print---------------------------
t = 0
If nob < 4 Then
Print "please insert a number >= 4"
Else
For a = 1 To nob - 3
For b = 2 To nob - 2
For c = 3 To nob - 1
For d = 4 To nob
If a < b And b < c And c < d Then
t = t + 1
ary(t, 1) = a
ary(t, 2) = b
ary(t, 3) = c
ary(t, 4) = d
List1.AddItem "第" & t & "种排列:" & ary(t, 1) & ary(t, 2) & ary(t, 3) & ary(t, 4)
End If
Next d
Next c
Next b
Next a
DoEvents
End If
End Sub
______________________________以下是选取的程式码______________
Private Sub Command2_Click()
Cls
x = Text1.Text
k = 1
List2.AddItem "第" & k & "个工作站内容:" & ary(x, 1) & ary(x, 2) & ary(x, 3) & ary(x, 4)
End Sub
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.114.54.243