Computing.Net > Forums > Programming > Ascending Array

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Ascending Array

Reply to Message Icon

Name: mobius2
Date: May 11, 2005 at 16:00:46 Pacific
OS: XP Pro
CPU/Ram: Pentium 4
Comment:

Hi Every one. Lottery prediction. Does any one know the code for VB6 to arrange 6 randomly generated numbers to.
1. Using an array to sort numbers into Ascending numerical order. Lowest to highest.
2.The code to put ascending numbers into labels which have already been designed.
3. To put colours into circles.

Must be an array, i have used bubble sort with no luck. Many thanks for any advice. regards bill Underwood



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: May 11, 2005 at 23:31:08 Pacific
Reply:

Why didn't the bubble sort work? It is ideal for sorting an array of six numbers.

You need to explain the second two questions a bit more. At a guess I would say:

For a = 1 to 6
Label1(a).Caption = Array(a)
Next

That is assuming you are using and Control Array of six label to correspond to the six numbers.

Stuart


0

Response Number 2
Name: mobius2
Date: May 13, 2005 at 07:51:44 Pacific
Reply:

Dear Stuart, Thanks for the reply. The bubble sort may not have been the correct formula or i may have missed one or two digits out, it just kept on saying sytex error all the time. I thought the array would be slightly quicker although i ma unsure that it would. When the 6 random numbers are generated, the are put into the suares by the code Label1. caption = print, which works well, but they are not in a ascending numerical order.

If you know off the code to put them in ascending numerical order, ie 1-49 range that would be great. If you think bubble sort would be better can you send the code for that, as i am new to this programming world. Best personal regards bill Underwood.


0

Response Number 3
Name: StuartS
Date: May 13, 2005 at 10:22:29 Pacific
Reply:

If you were getting Syntax Error all it means is that that there is something wrong with what you typed - a simple typing error perhaps. Could be something as simple as a misplaced comma.

You can get a Bubble Sort Algorithm hear:

http://zone.ni.com/devzone/conceptd.nsf/webmain/60E39A753406EE7986256E5C000030C6

Stuart


0

Response Number 4
Name: mobius2
Date: May 15, 2005 at 12:55:04 Pacific
Reply:

Dear Stuart,
MAny thanks for the e-mail for National Instruments website.Unfortunatly i do not know which part i need to go into for the code, as there were so many parts that i do not want to do something wrong or copy code that is copyrighted, can you please advise, many thanks for all your help.best regards bill underwood.


0

Response Number 5
Name: StuartS
Date: May 15, 2005 at 13:37:33 Pacific
Reply:

This bit:

Public Sub BubbleSort(ByRef sortArray() As Integer)
Dim i As Integer
Dim j As Integer
Dim Temp As Integer
For i = LBound(sortArray) To UBound(sortArray)
For j = LBound(sortArray) To (UBound(sortArray) - i - 1)
If sortArray(j + 1) < sortArray(j) Then
Temp = sortArray(j) 'swap if the two items
sortArray(j) = sortArray(j + 1) 'are out of order
sortArray(j + 1) = Temp
End If
Next j
Next i
End Sub

I wouldn't worry about copyright in this case. The bubble sort is a old as computers themselves. If you don't use this code there are bound to be hundreds of other examples on the Internet. This was just the first one I came to.

Stuart


0

Related Posts

See More



Response Number 6
Name: mobius2
Date: May 19, 2005 at 16:20:17 Pacific
Reply:

Dear Stuart, Many thanks, i will give it a try and see if it comes out ok and let you know in due course. Best personal regards bill underwood.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Ascending Array

array question in C www.computing.net/answers/programming/array-question-in-c/10350.html

sorting an array of string in java www.computing.net/answers/programming/sorting-an-array-of-string-in-java/18011.html

Comparing lines in array perl www.computing.net/answers/programming/comparing-lines-in-array-perl/18012.html