How to generating random number in vb.net code
Steps to create a random number generator
Step1: File new project ->windows forms application -> rename random number generate
Step2: Drag and drop the one button, four textboxes from tool box
Step3: Rename button as generate
Step4: Double click the generate button
Copy and paste this code
Private Sub Button1_Click(ByVal sender AsSystem.Object, ByVale As System.EventArgs) _ Handles Button1.Click
TextBox1.Text = Int(Rnd() * 9999)
TextBox2.Text = Int(Rnd() * 9999)
TextBox3.Text = Int(Rnd() * 9999)
TextBox4.Text = Int(Rnd() * 9999)
End Sub
Step5: Run the application
You can alternate the code also
TextBox1.Text = "A" & Int(Rnd() * 10) & Int(Rnd() * 99) & "D" & Int(Rnd() * 1
TextBox2.Text = Int(Rnd() * 10) & "B" & Int(Rnd() * 99) & Int(Rnd() * 10) & "F"
TextBox3.Text = "A" & Int(Rnd() * 10) & Int(Rnd() * 99) & "C" & Int(Rnd() * 10)
TextBox4.Text = Int(Rnd() * 10) & "B" & Int(Rnd() * 99) & Int(Rnd() * 10) & "D"
No comments:
Post a Comment