jeudi 29 janvier 2015

VS 2013- ASSIGN RANDOM NUMBERS WITHIN TEXTBOXES FROM LEAST TO GREATEST

Hello everyone I am having trouble with creating a number generator. Yes, another one. I’m using visual studio ultimate 2013, and I’m fairly new to it. I am trying to create a generator that gives the user the ability to change what numbers they want to be randomized. For instance randomizing odds only or evens only and displaying each result in its own separate textbox. I have figured that out even if it’s a rugged code, however I’m having a difficult time displaying the numbers in order from least to greatest without changing the numbers location relative to its assigned textbox. Essentially I want textbox2 to recognize whether or not it’s greater than textbox1, and if it’s not, then re-randomize a new number and continue to do so until that condition is met. I have tried using do, while, until, for loops and even tried using a delay, or sleep but I think this is beyond my scope because the program freezes on me. I have an example of my code below. Any help would be appreciated.



Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Randomize()
numbers = Int(9 * Rnd())
If numbers = "0" Then
TextBox1.Text = 2
End If
If numbers = "1" Then
TextBox1.Text = 4
End If
If numbers = "2" Then
TextBox1.Text = 6
End If
If numbers = "3" Then
TextBox1.Text = 8
End If
If numbers = "4" Then
TextBox1.Text = 10
End If
If numbers = "5" Then
TextBox1.Text = 12
End If
If numbers = "6" Then
TextBox1.Text = 14
End If
If numbers = "7" Then
TextBox1.Text = 16
End If
End Sub




Aucun commentaire:

Enregistrer un commentaire