求助:调换一组字符串中字符的顺序
随便输入一组字符串,比如说是:abcde,我想把这组字符串中的第1个字符和第3个字符调换一下,形成新的新符串:cbade。请问如何实现?谢谢!
Public Function 对换字符(cs As String, wz1 As Long, wz2 As Long) As String
Dim j() As Byte
Dim o As Long
Dim k As Byte
Dim m1 As Long, m2 As Long
m1 = wz1 - 1 '因为位置原点不同,这里进行修正
m2 = wz2 - 1
j = StrConv(cs, vbFromUnicode)
o = UBound(j)
If m1 < o And m1 >= 0 And m2 >= 0 And m2 < o And m1 <> m2 Then
k = j(m1)
j(m1) = j(m2)
j(m2) = k
End If
对换字符 = StrConv(j, vbUnicode)
End Function