Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim al As String, a1 As String, a2 As String, a3 As String, a4 As String, a5 As String, a6 As String, a7 As String, a8 As String, a9 As String, a10 As String
Dim rand As New Random
Dim num1 As Integer
num1 = rand.Next(1, 10)
MsgBox(num1)
a1 = a1
a2 = a2
a3 = a3
a4 = a4
a5 = a5
a6 = a6
a7 = a7
a8 = a8
a9 = a9
a10 = a10
End Sub
End Class
Tag : .NET
Date :
2016-12-02 11:05:26
By :
yainalove2015
View :
5584
Reply :
2
No. 1
Guest
Code (C#)
public class RandomNumber
{
public int StartNumber { set; get; }
public int EndNumber { set; get; }
private List<int> Numbers;
private Random r = new Random();
private void InitNumber()
{
for (int i = StartNumber; i <= EndNumber; i++)
this.Numbers.Add(i);
}
public void Start()
{
InitNumber();
}
public void Reset()
{
this.Numbers.Clear();
}
public int NextNumber()
{
int randomIndex = r.Next(this.Numbers.Count);
int number = this.Numbers[randomIndex];
this.Numbers.RemoveAt(randomIndex);
return number;
}
}
public void Print()
{
int start = 1, end = 36;
RandomNumber r = new RandomNumber();
r.StartNumber = 1;
r.EndNumber = 36;
r.Start();
for (int index = start; index < end; index++)
Console.WriteLine(r.NextNumber());
}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For i As Integer = 1 To 36
Dim rn As New Random()
RichTextBox1.Text += vbCrLf & rn.Next(1, 36)
Threading.Thread.Sleep(100)
Next
End Sub