What is the simplest way to extract numbers form a string?
e.g.
jimbo4foo5
to return
45
What is the simplest way to extract numbers form a string?
e.g.
jimbo4foo5
to return
45
The only way that comes immediately to mind is a function that checked each character and only passed the numeric ones.
Depends on where you're trying to do it, but in VBA code here's one approach, where String2Parse is just that:
Code:Private Sub String2Parse_AfterUpdate() Dim i As Integer Dim ParsedNumber As String If Not IsNull(Me.String2Parse) Then For i = 1 To Len(Me.String2Parse) If Mid(Me.String2Parse, i, 1) Like "[0-9]" Then ParsedNumber = ParsedNumber & Mid(Me.String2Parse, i, 1) End If Next i MsgBox ParsedNumber End If End Sub
Linq ;0)>
Thanks - I will use that in the future. That was sort of what I thought I would have to do (parse) except I was hoping for native access function
anyway I used the left() function to extract the text of the name of the control then added the number using a counter x
it let me cycle through 34 form controls (starting from 0) with the same name and iteration of x
Works well
edit _