vb.net随机生成数字,vb中随机生成数字
怎么用vb.net随机产生5个不同的数,范围1-33,求帮忙改一下
Private Sub Command1_Click()
成都创新互联公司主要从事成都网站制作、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务天镇,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
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 随机出数字,但要求包含特定数字如何做?
下面是你需要的,经过三次随机,可以看一下,直接调用函数返回一个字符就是你要的,看不懂再追问哈
Structure jiqi
Dim num As Integer
Dim num2 As Integer
End Structure
Public Function chansheng() As String
Dim str As String = ""
Dim n As Integer = 0
Dim p68 As Integer
Randomize()
p68 = Int(Rnd() * 2) + 1
Dim a(10), b(8) As Integer
For i = 1 To 6
b(i) = i - 1
Next
b(7) = 7
b(8) = 9
For i = 1 To 6
Randomize()
a(i) = b(Int(Rnd() * 8) + 1)
Next
If p68 = 1 Then
For i = 7 To 10
a(i) = 6
Next
ElseIf p68 = 2 Then
For i = 7 To 10
a(i) = 8
Next
End If
Dim c(10) As Integer
Dim temp As jiqi
Dim pi(10) As jiqi
For i = 1 To 10
pi(i).num = a(i)
pi(i).num2 = Int(Rnd() * 1000) + 10
Next
For i = 1 To 10
For j = 1 To 10 - i
If pi(j).num2 pi(j + 1).num2 Then
temp = pi(j + 1)
pi(j + 1) = pi(j)
pi(j) = temp
End If
Next j
Next i
For i = 1 To 10
str = str pi(i).num
Next
Return str
End Function
vb.net怎么随机生成5个不同是数(1-33内的数),大神求救
想要生成多少个都行。
Randomize()随机打乱
dim a1 as integer=cint(rnd()*32))+1
dim a2 as integer=cint(rnd()*32))+1
dim a3 as integer=cint(rnd()*32))+1
dim a4 as integer=cint(rnd()*32))+1
dim a5 as integer=cint(rnd()*32))+1
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怎样生成随机数
Dim a As Integer = CInt(Int((9999 - 1000 + 1) * Rnd() + 1000))
注:randomvalue = CInt(Int((upperbound - lowerbound + 1) * Rnd() + lowerbound))
这里,upperbound 是此范围内最大的数,lowerbound 是此范围内最小的数。
VB.NET中随机产生十个数字
下面的代码已经经过测试
Private Sub RandList()
Dim I As Integer
Dim R As New System.Random
ListBox1.Items.Clear()
For I = 1 To 10
ListBox1.Items.Add(R.Next(30, 100).ToString)
Next
End Sub
分享题目:vb.net随机生成数字,vb中随机生成数字
网址分享:http://scyanting.com/article/hodgop.html