Create arrays of the textbox controls you have and then write a simple bubble sort. Bubble sort is slow, but more than fast enough for small amounts of data.
Dim arrA() As Textbox = {a1, a2, a3, a4, a5}
Dim arrB() As Textbox = {b1, b2, b3, b4, b5}
Dim Changed as Boolean
Do
Changed = False
For i = 0 to arrB.Count - 2 'Stop at the second to last array item because we check forward in the array
If CInt(arrB(i).Text) > CInt(arrB(i + 1).Text) Then 'Next value is smaller than previous --> Switch values, also switch in arrA
Dim Temp as String = arrB(i + 1).Text
arrB(i + 1).Text = arrB(i).Text
arrB(i).Text = Temp
Temp = arrA(i + 1).Text
arrA(i + 1).Text = arrA(i).Text
arrA(i).Text = Temp
Changed = True
End If
Next
Loop Until Changed = False 'Cancle the loop when everything is sorted
Now the textbox values are sorted and you can display the results whereever you want.
To display the values in the labels, say called l1-l5:
Dim arrL() as Label = {l1, l2, l3, l4, l5}
For i = 0 to 4
arrL(i).Text = arrA(i).Text
Next
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…