'试了一下很不错,感谢分享
'稍作修改,自用
Option Explicit
Sub test()
Dim s
s = "各位大神好h,323!2$%^hh,啊d做"
MsgBox s & vbNewLine & py(s)
End Sub
Function py(s) As String
Dim mark, i, j
mark = "吖八攃咑妸发旮哈咗丌咔垃妈乸噢帊七冄仨他咗咗屲夕丫帀咗"
' s = Trim(Replace(Replace(s, Space(1), vbNullString), vbTab, vbNullString))
' If Len(s) = 0 Then Exit Function
For i = 1 To Len(s)
If Mid(s, i, 1) Like "[一-龥]" Then
For j = Len(mark) To 1 Step -1
If StrComp(Mid(s, i, 1), Mid(mark, j, 1), vbTextCompare) = 1 Then _
py = py & Chr(64 + j): Exit For
Next
Else
py = py & Mid(s, i, 1)
End If
Next
End Function |