Click here to Skip to main content
15,067,335 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is my code

Dim CalulateWinnersArray(My.Settings.ModelScores.Count) As Integer

      'check if there is models in the system or not
      If My.Settings.ModelScores.Count = 0 Then
          MessageBox.Show("No Models In The System!")

          'searches for the model and there scores and removes them
          Dim addtomodelcount = 0
          While addtomodelcount < My.Settings.ModelScores.Count

              Dim thesplit As String() = Split(My.Settings.ModelScores(addtomodelcount), ",")
              CalulateWinnersArray(addtomodelcount) = thesplit(1)

              addtomodelcount = addtomodelcount + 1
          End While
          HighestScoreLabel.Text += CalulateWinnersArray.Sort()
      End If

the modelscore's is just a string collection with numbers like


and im adding all the 0 indexes into the CalulateWinnersArray array and im have to do a bubble sort for a school assiment, I know what the ubbble sort looks like in psumocode, but i don't know how to put it into this code, I want HighestScoreLabel.Text to = the hiest score in the array.

so for example the CalulateWinnersArray should look like a whole bunch of random numbers, adding into the array kinda like this:


and they will be sorted in order, so the highest score will be at index 0, then HighestScoreLabel.Text will = 0 in the array which will be 76 because it is the highest.

Can anyone please help me with this??

There is no need to reinvent this because it is already built in. Check here:[^]

Good luck!
[no name] 5-Apr-13 5:53am
I looked at it and i added this to the code

Dim reversedIDigits = (From d In CalulateWinnersArray Where d(1) = "i" Select d).Reverse()


and i got this error for the "d" at "Where d(1)" The error is

Error 1 Expression is not an array or a method, and cannot have an argument list.
E.F. Nijboer 5-Apr-13 6:21am
d is an item from the set of CalulateWinnersArray. d is not an array, but a placeholder for a single element. Where did you come up with i anyway?
[no name] 5-Apr-13 6:23am
the site you gave me, so i turn "d" in to an integer and I get this error

Error 1 Range variable 'd' hides a variable in an enclosing block or a range variable previously defined in the query expression.
E.F. Nijboer 5-Apr-13 10:13am
How about trying:
HighestScoreLabel.Text += From w In CalulateWinnersArray Order By w

Instead of:
HighestScoreLabel.Text += CalulateWinnersArray.Sort()
[no name] 6-Apr-13 6:14am
I don't understand
E.F. Nijboer 8-Apr-13 4:49am
You can use LINQ for this. Have you tried it? and looked at the link above?
Sorting techniques have bneen covered extensivly in some articles on this page:
Visualization and comparison of sorting algorithms in C#[^]
[no name] 5-Apr-13 6:02am
need vb code, not C# sorry
Kenneth Haugland 5-Apr-13 6:03am
[no name] 5-Apr-13 6:10am
i did this with the code and then i got lost with the redrawitem part, i dunno what element that is

Dim n As Integer = CalulateWinnersArray.Count - 1
For i As Integer = 0 To n - 1
For j As Integer = n To i + 1 Step -1
If DirectCast(CalulateWinnersArray(j - 1), IComparable).CompareTo(CalulateWinnersArray(j)) > 0 Then
Dim temp As Object = CalulateWinnersArray(j - 1)
CalulateWinnersArray(j - 1) = CalulateWinnersArray(j)
CalulateWinnersArray(j) = temp
RedrawItem(j - 1)
If chkCreateAnimation.Checked Then
End If
End If

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900