在VB排序中,三个文本框内随意输入0到9的数字允许输入相同的数字,如何编写代码来实现。求教高手!谢谢!

2024-11-13 03:47:03
推荐回答(1个)
回答(1):

Private Sub Form_Click()
Dim a(3) As Integer
a(1) = Text1.Text
a(2) = Text2.Text
a(3) = Text3.Text

For i = 1 To 2
For j = i To 3
If a(i) < a(j) Then
tmp = a(i)
a(i) = a(j)
a(j) = tmp
End If
Next
Next

Text4.Text = ""

For i = 1 To 3
Text4.Text = Text4.Text & a(i)
Next

End Sub

Private Sub Form_Load()
Text1.Text = "0"
Text2.Text = "0"
Text3.Text = "0"
Text4.Text = ""

End Sub