怎么用vb.net随机产生5个不同的数,范围1-33,求帮忙改一下
PrivateSubForm1_click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBa...
Private Sub Form1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Click
TextBox1.Text = ""
Dim rnd As New Random()
Dim b(4) As Byte
rnd.NextBytes(b)
Console.WriteLine("the random bytes are :")
Dim i As Integer
For i = 0 To 4
Console.Write(i)
Console.Write(":")
Console.WriteLine(b(i))
Next i
For j = 0 To 4
TextBox1.Text &= b(j) & " " & vbCrLf
Next
End Sub 展开
TextBox1.Text = ""
Dim rnd As New Random()
Dim b(4) As Byte
rnd.NextBytes(b)
Console.WriteLine("the random bytes are :")
Dim i As Integer
For i = 0 To 4
Console.Write(i)
Console.Write(":")
Console.WriteLine(b(i))
Next i
For j = 0 To 4
TextBox1.Text &= b(j) & " " & vbCrLf
Next
End Sub 展开
1个回答
展开全部
Private Sub Command1_Click()
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询