那位高手知道在vba中将字符串变为字符型的数组?
发布网友
发布时间:2023-08-08 08:47
我来回答
共2个回答
热心网友
时间:2023-09-21 18:04
你测试一下下面的代码,可能对你有帮助;
Sub test()
Dim L As Long
Dim Mystr As String
Dim i As Long
Dim MySi As String, Si As String
Mystr = "fdsaf4.56454dsaf"
L = Len(Mystr)
For i = 1 To L
MySi = Mid(Mystr, i, 1)
If VBA.IsNumeric(MySi) = True Or MySi = "." Then
Select Case i
Case Is = 1
Si = MySi
Case Is > 1
Si = Si & MySi
End Select
End If
Next i
MsgBox "字符串“" & Mystr & "”中包含有数字" & Si
End Sub
热心网友
时间:2023-09-21 18:04
Function GetNumber(v As String)
sz = "0123456789."
For i = 1 To Len(v)
c = Mid(v, i, 1)
If InStr(sz, c) > 0 Then
GetNumber = GetNumber & c
End If
Next
End Function