Private Sub Command1_Click()
Dim a() As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim n As Integer
Dim s As String
Dim max As String
Dim min As String
s = Text1
n = Len(s)
ReDim a(1 To n) As Integer
For i = 1 To n
a(i) = Val(Mid(s,i,1))
Next i
For i = 1 To n
For j = 1 To n - i
If a(j) < a(j + 1) Then
k = a(j)
a(j) = a(j + 1)
a(j + 1) = k
End If
Next j
Next i
For i = 1 To n
max = max & a(i)
min = a(i) & min
Next i
Text2 = max
Text3 = min
End Su