Function MyGet(Srg As String, Optional n As Integer = False)
Dim i As Integer
Dim s, MyString As String
Dim Bol As Boolean
For i = 1 To Len(Srg)
s = Mid(Srg, i, 1)
If n = 1 Then
Bol = Asc(s) < 0
ElseIf n = 2 Then
Bol = s Like "[a-z,A-Z]"
ElseIf n = 0 Then
Bol = s Like "#"
End If
If Bol Then MyString = MyString & s
vba 字符串函数Next
MyGet = IIf(n = 1 Or n = 2, MyString, Val(MyString))
End Function '从第一个字符开始,提取数字、字母、汉字。如果想要文本型数字,可以不加val。或者直接myget=mystring
Function MyGet(Srg As String, Optional n As Integer = False, Optional start_num As Integer = 1)
Dim i As Integer
Dim s, MyString As String
Dim Bol As Boolean
For i = start_num To Len(Srg)
s = Mid(Srg, i, 1)
If n = 1 Then
Bol = Asc(s) < 0
ElseIf n = 2 Then
Bol = s Like "[a-z,A-Z]"
ElseIf n = 0 Then
Bol = s Like "#"
End If
If Bol Then MyString = MyString & s
Next
MyGet = IIf(n = 1 Or n = 2, MyString, Val(MyString))
End Function '第三个参数是指定开始提取的字符数。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论