Visual Basic Exp 2005 Sorting
Hi there,
I am a business student but have a small problem solving project to do. I have to contruct a lottery system that generates 7 random numbers 1-49. I have done this, but i also have to arrange them. I have been looking into buble sort ect but nothing helpd so far so I was hoping someone could kindly help. My code so far is bellow. I have used 7 labels, one button. The labels are in a groupbox as I was trying to arrange them in ascending orde but kept failingr. Thanks a lot for your time and help.
ivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim intarray(49) As Integer
Dim intcount As Integer
Dim intindex As Integer
Dim intnumber
Dim repeated As Boolean
Dim obj As Object
Label1.Text = intarray(0)
Label2.Text = intarray(1)
Label3.Text = intarray(2)
Label4.Text = intarray(3)
Label5.Text = intarray(4)
Label6.Text = intarray(5)
Label7.Text = intarray(6)
For intcount = 0 To 6
Do
repeated = False
intnumber = Int((50 * Rnd()) + 1)
For intindex = 0 To 6
If intnumber = intarray(intindex) Then
repeated = True
End If
Next
Loop Until repeated = False
intarray(intcount) = intnumber
Next
intindex = -1
For Each obj In GroupBox1.Controls
intindex += 1
obj.text = intarray(intindex)
|