用VB从1-12这12个数中随机生成3个互不重复的数
答案:3 悬赏:40 手机版
解决时间 2021-03-27 21:50
- 提问者网友:轻浮
- 2021-03-27 11:22
用VB从1-12这12个数中随机生成3个互不重复的数
最佳答案
- 五星知识达人网友:傲气稳了全场
- 2021-03-27 11:34
解:
private sub command1_click()
randomize
dim a as integer ,b as integer ,c as integer
a=int(rnd*12)+1
text1=a
do
b=int(rnd*12)+1
loop until b<>a
text2=b
do
c=int(rnd*12)+1
loop until c<>b and c<>a
text3=c
end sub
private sub command1_click()
randomize
dim a as integer ,b as integer ,c as integer
a=int(rnd*12)+1
text1=a
do
b=int(rnd*12)+1
loop until b<>a
text2=b
do
c=int(rnd*12)+1
loop until c<>b and c<>a
text3=c
end sub
全部回答
- 1楼网友:空山清雨
- 2021-03-27 12:29
弄个数组就搞定了。追问晕。大哥,我是小白啊,不知道什么数组。如果会的话直接给出一个程序吧。追答
- 2楼网友:北城痞子
- 2021-03-27 11:43
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer
Randomize
Do
a = Int(Rnd * 12) + 1 '分别生成三个数
b = Int(Rnd * 12) + 1
c = Int(Rnd * 12) + 1
Loop While a = b Or b = c Or a = c '如果有任何两个数相同就再次生成
Text1.Text = a '把数值分别放到三个文本框中
Text2.Text = b
Text3.Text = c
End Sub
Dim a As Integer, b As Integer, c As Integer
Randomize
Do
a = Int(Rnd * 12) + 1 '分别生成三个数
b = Int(Rnd * 12) + 1
c = Int(Rnd * 12) + 1
Loop While a = b Or b = c Or a = c '如果有任何两个数相同就再次生成
Text1.Text = a '把数值分别放到三个文本框中
Text2.Text = b
Text3.Text = c
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯