ش | ی | د | س | چ | پ | ج |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
استخراج عدد از تکست نمونه ای که در اینترنت در سایت خارجی یافت شده جهت استفاده اینجا یکم بهم ریختست
Function GetNumber(ByVal pStr As String) As Long
Dim intLen As IntegerDim n As IntegerpStr = Trim(pStr) 'removes leading & trending spacesintLen = Len(pStr) 'stores original lengthn = 1 'consider this a counter & position markerIf pStr = "" Or IsNull(pStr) Or intLen = 0 Then Exit Function 'validate we didn't get passed an empty/null stringDoIf IsNumeric(Mid(pStr, n, 1)) Then 'check if that single character is a numberGetNumber = GetNumber & Mid(pStr, n, 1) 'if it is add to existing ones if anyLoop Until intLen = (n - 1) 'go until we processed all characters. The reason we have to do n-1 is that Len starts at 0 & we told n to start at 1n = n + 1 'add to counter so we know to go to next character on the next pass/loopElse n = n + 1 'it wasn't a number, add to counter so we know to skip itEnd Function 'if no numbers function will return default value of data type, in our case long would be 0End If
All cred