Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (1 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
        Try

            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)
                Else
                    TextBox25.Text = (lastScorePosition & ",")
                End If
                position += 1
            Next


        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            Beep()
        End Try
Posted
Updated 25-Oct-19 22:06pm

1 solution

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.
 
Share this answer
 
Comments
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900