Private Sub Command1_Click()
Dim s As String
s = Text1.Text
For i = 1 To Len(s) ' 循环遍历每一个字符
For j = Len(s) To i + 1 Step -1 ' 从后往前冒泡
If Asc(Mid(s, j, 1)) < Asc(Mid(s, j - 1, 1)) Then ' 如果后一个比前一个小,那么就交换冒泡
t = Mid(s, j, 1) ' 这三句是交换的过程
Mid(s, j, 1) = Mid(s, j - 1, 1)
Mid(s, j - 1, 1) = t
End If
Next j, i
Text1.Text = s
End Sub