vb.net随机数,vbs随机数

怎么用vb.net随机产生5个不同的数,范围1-33,求帮忙改一下

Private Sub Command1_Click()

成都创新互联-专业网站定制、快速模板网站建设、高性价比孝南网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式孝南网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖孝南地区。费用合理售后完善,十多年实体公司更值得信赖。

Dim num(6) As Integer

Dim i As Integer, j As Integer

Dim tmp As Integer

Randomize '防止每次生出随机数一样

For i = 0 To 5

num(i) = Int(Rnd * 53) + 1

Next

PrintNum "新生成的6个随机数为:", num()

For i = 0 To 5

For j = 0 To 5

If num(j) num(j + 1) Then

tmp = num(j)

num(j) = num(j + 1)

num(j + 1) = tmp

End If

Next

Next

PrintNum "排序后的6个随机数为:", num()

End Sub

编写一个 VB.NET 程序,产生 100 个 100 以内的随机数,将他们从大到小排序后输出

Private Sub Command1_Click()

Dim a(1 To 100) As Integer

Dim i As Integer, j As Integer, k As Integer

For i = 1 To 100 '给数组a一百个元素赋值,并换每行十个数字输出来窗体上

a(i) = Int(Rnd * 101)

k = k + 1

Print Tab((k - 1) * 5); a(i);

If k = 10 Then k = 0: Print

Next i

Print

Print

For i = 100 To 2 Step -1 '用冒泡排序法对数组进行排序

For j = 1 To i - 1

If a(j) a(j + 1) Then

t = a(j): a(j) = a(j + 1): a(j + 1) = t

End If

Next j

Next i

For i = 1 To 100 '输出排好序的数组

k = k + 1

Print Tab((k - 1) * 5); a(i);

If k = 10 Then k = 0: Print

Next i

End Sub

vb.net中产生三位正整数的随机数的程序写法

'项目:VB中产生在一定正整数范围内的不重复的随机数'作者:qq15495835Private Sub Command1_Click() Max = 100 '随机数上限值 Min = 1 '随机数下限值 Amount = 10 '产生号码数量(数量值应小于随机数上限值-随机数下限值)否则会产生死循环 ReDim a(Amount) Randomize For i = 0 To Amount a(i) = Int((Max - Min + 1) * Rnd + Min) For j = 0 To i If i j And a(i) = a(j) Then i = i - 1 Next Next Text1 = Join(a, vbCrLf)End Sub'请采纳参考!谢谢!

vb.net程序,利用随机函数产生100个1到100之间的整数,求其中的最大最小值。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Randomize() '产生随机数种子 以防止每次生成结果都一样

Dim a(100) As Integer '声明数组存放数据 用来保存随机数结果

Dim max As Integer, min As Integer '声明两个变量存最大值和最小值

min = 1000 : max = 0 '设置初值

For i = 0 To 99 '循环100次

a(i) = Int(Rnd() * 1000 + 1) '用rnd生成一个随机数 由于rnd范围为0-1之间的小数.所以*1000设置他的范围为0到999之间 加1变成1到1000之间

If a(i) = max Then max = a(i) '如果当前数值大于最大值的变量就保存

If a(i) = min Then min = a(i) '如果当前数值小于最小值的变量就保存

Next

MsgBox("最大值为" max)

MsgBox("最小值为" min)

End Sub


文章题目:vb.net随机数,vbs随机数
当前链接:http://scyanting.com/article/dssgpop.html