Function test(s As String) As String
Dim reg As Object
Set reg = CreateObject("vbscript.regexp")
With reg
.Global = True
.Pattern = "[A-Za-z0-9]+"
test = .Replace(s, "")
End With
End Function作者: jsleee 時間: 2024-3-30 23:27
撰寫函式程式
https://learn.microsoft.com/zh-tw/office/vba/language/concepts/getting-started/writing-a-function-procedure
Function test(s As String) As String
定義
Dim reg As Object
正規表示式物件
Set reg = CreateObject("vbscript.regexp")
With reg
全局匹配模式
.Global = True
匹配模式 大小寫a~z,數字 0~9
.Pattern = "[A-Za-z0-9]+"
把大小寫a~z,數字 0~9,用空白取代
test = .Replace(s, "")
End With
End Function作者: jsleee 時間: 2024-3-31 07:49
Option Explicit
Sub TEST()
Dim T$
T = "1100中文中文中文...AABBCC"
T = Replace(1 & T, Val(1 & T), "")
MsgBox T
T = Mid(T, 1, Evaluate("LENB(""" & T & """)") - Len(T))
MsgBox T
End Sub作者: hcm19522 時間: 2024-4-2 10:27