|
-
Apr 4th, 2006, 02:22 AM
#11
Conquistador
Re: Getting only numbers out of a string
Option Explicit
Private Sub Form_Load()
Dim Str As String
Str = "Now is the time for all 45 good men to come to the aid of the 4th party"
Debug.Print ExtractNumber(Str)
End Sub
Public Function ExtractNumber(Phrase As String) As String
Dim Phr() As Byte
Dim i As Long
Dim n As Long
Phr = Phrase
n = UBound(Phr)
For i = 0 To n Step 2
If Phr(i) > 47 And Phr(i) < 58 Or Phr(i) = Asc(".") Then
ExtractNumber = ExtractNumber & ChrW$(Phr(i))
End If
Next
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|