|
-
October 18th, 1999, 03:49 PM
#1
Sorting Integer arrays
Hi,
I'm taking a VB course at evening class and I have been given the task of generating lottery numbers.
I need to sort the generated numbers into ascending order and display them at the bottom of the form. I have tried putting the values into a sorted listbox but this seems to add a second copy of the numbers.
eg 1, 1, 23, 23 .....
Can anyone help?
I would be most grateful for any suggestions.
-
October 18th, 1999, 04:30 PM
#2
Re: Sorting Integer arrays
Not to do your homework or anything, but here you go: (I ought to tell your teacher of this!!!)
for a = LBound(Lottery) to UBound(Lottery) 'Pass through the array once for every index.
for b = LBound(Lottery) to UBound(Lottery) - 1
If Lottery(b) > Lottery(b + 1) then 'Swap positions if number is greater
temp = Lottery(b + 1)
Lottery(b + 1) = Lottery(i)
Lottery(b) = temp
End If
next
next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|