Const N = 10   'データの個数

 

Private Sub all_clear_Click()

    For k = 0 To N - 1

      Text1(k).Text = " "

      Label1(k).Caption = " "

      Label2(k).Caption = " "

      Label3(k).Caption = " "

    Next k

End Sub

 

Private Sub dsort_Click()

Dim x(N)

Dim r(N)

For k = 0 To N - 1

   x(k) = Val(Text1(k).Text)

   r(k) = k

Next k

For i = 1 To (N - 1)

   For j = 0 To (N - 1) - i

      If x(j) > x(j + 1) Then

        xx = x(j)

        x(j) = x(j + 1)

        x(j + 1) = xx

        rr = r(j)

        r(j) = r(j + 1)

        r(j + 1) = rr

      End If

   Next j

Next i

For k = 0 To N - 1

   Label2(k) = r(k) + 1

   Label3(k) = x(k)

Next k

End Sub

 

Private Sub end_Click()

  End

End Sub

 

Private Sub rank_Click()

Dim x(N)

Dim y(N)

Dim r(N) As Integer

For k = 0 To N - 1

   x(k) = Val(Text1(k).Text)

   y(k) = x(k)

   r(k) = k

Next k

For i = 1 To (N - 1)

   For j = 0 To (N - 1) - i

      If x(j) < x(j + 1) Then

         xx = x(j)

         x(j) = x(j + 1)

         x(j + 1) = xx

         rr = r(j)

         r(j) = r(j + 1)

         r(j + 1) = rr

      End If

   Next j

Next i

Label1(r(0)) = 1

For k = 1 To N - 1

   If y(r(k - 1)) = y(r(k)) Then

      Label1(r(k)) = Label1(r(k - 1))

   Else

      Label1(r(k)) = k + 1

   End If

Next k

nd Sub

 

Private Sub sort_Click()

Dim x(N)

Dim r(N)

For k = 0 To N - 1

   x(k) = Val(Text1(k).Text)

   r(k) = k

Next k

For i = 1 To (N - 1)

   For j = 0 To (N - 1) - i

      If x(j) < x(j + 1) Then

         xx = x(j)

         x(j) = x(j + 1)

         x(j + 1) = xx

         rr = r(j)

         r(j) = r(j + 1)

         r(j + 1) = rr

      End If

   Next j

Next i

For k = 0 To N - 1

   Label2(k) = r(k) + 1

   Label3(k) = x(k)

Next k

End Sub

 

Private Sub clear_Click()

For k = 0 To N - 1

   Text1(k).Text = " "

Next k

End Sub