怎么分解字符串?
我想取出字符串的一个数字,该怎样取?
比如字符串“冲裁孔3”.其中的数字可以是多位的。该怎样把数字截取出来?
[解决办法]
Option Explicit
Function GetNumber(S As String) As Double
Dim iLoop As Integer
GetNumber = 0
For iLoop = 1 To Len(S)
If Mid(S, iLoop, 1) > = "0 " And Mid(S, iLoop, 1) <= "9 " Then
GetNumber = CDbl(Mid(S, iLoop))
Exit For
End If
Next iLoop
End Function
Private Sub Form_Load()
Debug.Print GetNumber( "字符串中的数字123 ")
Debug.Print GetNumber( "字符串中的数字123.456 ")
End
End Sub