更好的是:
- Function testCmdrDuh(str2test As String, strPattern As String) As String
- Dim strFinal As String
- Dim I As Integer
- Dim strPat As String
- Do Until strPattern = ""
- strPat = Left(strPattern, 1)
- I = InStr(1, str2test, strPat)
- Do Until I = 0
- strFinal = strFinal & Mid(str2test, I, 1)
- str2test = Replace(str2test, strPat, "", 1, 1)
- I = InStr(1, str2test, strPat)
- Loop
- strPattern = Replace(strPattern, strPat, "", 1, 1)
- Loop
- testCmdrDuh = strFinal
- End Function
- Sub test()
- Debug.Print testCmdrDuh("PSSXPLPS", "PSLX")
- End Sub
|