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("请输入字符串", "", "1Ae4ui95487KuywY1Z2Faz")
f InS = "" Then Exit Sub
J = Len(InS)
For I = 1 To J
S = Mid(InS, I, 1)
T = T & S & " "
Next I
T = Trim(T)
C = Split(T, " ")
L = UBound(C)
'按逆序排列
Next I
扩展资料:
1、连接运算 concat(s1,s2,s3…sn) 相当于s1+s2+s3+…+sn.
例:concat(‘11’,'aa’)='11aa’;
2、求子串。 Copy(s,I,I) 从字符串s中截取第I个字符开始后的长度为l的子串。
例:opy(‘abdag’,2,3)=’bda’。
3、删除子串。过程 Delete(s,I,l) 从字符串s中删除第I个字符开始后的长度为l的子串。
例:s:=’abcde’;delete(s,2,3);结果s:=’ae’。
4、插入子串。 过程Insert(s1,s2,I) 把s1插入到s2的第I个位置。
例:s:=abc;insert(‘12’,s,2);结果s:=’a12bc’。
新建一工程,在窗体上拖入一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("请输入字符串", "", "1Ae4ui95487KuywY1Z2Faz")
If InS = "" Then Exit Sub
J = Len(InS)
For I = 1 To J
S = Mid(InS, I, 1)
T = T & S & " "
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
运行效果图: