
Originally Posted by
Ellis Dee
This forum is for intellectual exercises, not functional solutions.
not according to this:
The Purpose Of This Forum (by Brad Jones)
anyway, here's my attempt. I haven't programmed in vb6 in a while, and needed the challenge.
smaller code is "usually" faster but i'll let someone else benchmark it. I tried to keep mine as a direct replacement for the first function. If i were to write my own function, i would have made use of a string and split it into an array instead of using a method that required a variant.
Code:
Private Function GetNumbersbyStringI(ByRef s As String) As String()
Dim cl As Long, Tempchar As String, tempchar2 As String, TempNumString As String
Dim myarray() As String, arraycount As Long
For cl = 1 To Len(s)
Tempchar = Mid(s, cl, 1)
If IsNumeric(Tempchar) Then
Do
TempNumString = TempNumString + Tempchar
cl = cl + 1
Tempchar = Mid(s, cl, 1)
If Not IsNumeric(Tempchar) Then
arraycount = arraycount + 1
ReDim Preserve myarray(1 To arraycount)
myarray(arraycount) = TempNumString
TempNumString = ""
Exit Do
End If
Loop
End If
Next cl
GetNumbersbyStringI = myarray
End Function
Edit: Don't bother. It's about 50% slower. I actually managed to get this down to about 5 lines of code and every single thing i did (except getting rid of the redim preserve) slowed it down. I give up