VB中,有1-39个数字,任意随机选择其中某些数字(数量不限)然后两两组合,请问用VB该怎么写程序?

伟强1112022-10-04 11:39:541条回答

已提交,审核后显示!提交回复

共1条回复
记忆中的美 共回答了14个问题 | 采纳率100%
Private Sub Form_Load()
Dim i As Integer
Dim a() As Integer
Randomize
s = Int(10 * Rnd)
ReDim a(s)
For i = 0 To s '任意选择数量
p = Int(39 * Rnd)
a(i) = p
Text1.Text = Text1.Text & " " & p '随机数
Next i
Text1.Text = Trim(Text1.Text)
For d = 0 To s
For t = d + 1 To s
Text2.Text = Text2.Text & " " & a(d) & a(t)
Next t
Text2.Text = Text2.Text & vbCrLf
Next d
End Su
1年前

相关推荐