Click here to Skip to main content
14,426,399 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have 5 text-boxes in my form which take randomize value according to user inserted values in the previous process. I want to rank these textboxes according to their values, high-value textbox rank "1" lower value textbox "2" and so on

What I have tried:

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click

            Dim i As String() = New String() {TextBox20.Text, TextBox19.Text, TextBox18.Text, TextBox17.Text, TextBox16.Text}
            Dim lastScore As Double
            Dim lastScorePosition As Double
            Dim position As Double = 1

            For Each i1 In i
                If Val(lastScore) <> Val(i1) Then
                    TextBox25.Text = (position & ",")
                    lastScorePosition = position
                    lastScore = Val(i1)
                    TextBox25.Text = (lastScorePosition & ",")
                End If
                position += 1

        Catch ex As Exception
        End Try
Updated 25-Oct-19 23:06pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Take the text value from each box; convert it to an appropriate numeric format - Integer, Double, Float: we don't know what type of numbers you expect the user to enter - using the appropriate TryParse method and reporting problems to the user if they miskeyed; then store those values in an array. You can then use Array.Sort to order the values highest to lowest.
Amranullah Hassanzada 26-Oct-19 4:57am
Please, can you provide me complete code? thanks
OriginalGriff 26-Oct-19 5:54am
No - because this is your homework, and you wouldn't learn anything if I did.
And your tutor wants your thoughts, not mine!
Amranullah Hassanzada 26-Oct-19 8:57am
brother I am a civil engineer and I want to develop software, this is why I ask just about ranking and even i'm not a student now. please just help me I stake in this last part.

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100