新建一工程,在窗体上拖入一个Command控件即可。然后进代码区,删除所有代码后,粘贴以下代码即可:
Option Explicit
Private Sub Command1_Click()
Dim InS As String, S As String, T As String
Dim I As Integer, J As Integer, L As String
Dim C() As String, X As String
InS = InputBox("请输入字符串", "", "1Ae4ui95487KuywY1Z2F")
If InS = "" Then Exit Sub
J = Len(InS)
For I = 1 To J
S = Mid(InS, I, 1)
'找出所有大写字母,并保存在变量T中
If Asc(S) > 64 And Asc(S) < 91 Then
T = T & S & " "
End If
Next I
T = Trim(T)
C = Split(T, " ")
L = UBound(C)
'对字母按逆序排列
For I = 0 To L - 1
For J = I + 1 To L
If C(I) < C(J) Then X = C(I): C(I) = C(J): C(J) = X
Next J
Next I
'输出到窗体上
For I = 0 To L
Print C(I);
Next I
End Sub
运行效果,输入1Ae4ui95487KuywY1Z2F。结果如下图: