1、遍历每一个字符进行判断
@H_404_5@
Public Function DelNumber(ByVal s As String) As String
Dim strL As Long Dim i As Long Dim strTemp As String On Error GoTo err strL = Len(s) DelNumber = "" For i = 0 To strL - 1 strTemp = Left(Right(s,strL - i),1) If Not IsNumeric(strTemp) Then DelNumber = DelNumber & strTemp End If Next Exit Function err: MsgBox Error End Function@H_404_5@ 2、正则表达式
Public Function DelNumberReg(ByVal s As String) As String Dim oRegExp As Object Dim strDest As String,strSource As String strSource = s Set oRegExp = CreateObject("VBscript.RegExp") oRegExp.Global = True oRegExp.Pattern = "[0-9]*" strDest = oRegExp.Replace(strSource,"") DelNumberReg = strDest End Function原文链接:https://www.f2er.com/vb/259416.html