Results 1 to 35 of 35

Thread: Can you do it faster??

Threaded View

  1. #10
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: Can you do it faster??

    Quote Originally Posted by Ellis Dee View Post
    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
    Last edited by Lord Orwell; Jan 14th, 2011 at 05:16 AM.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width