Results 1 to 4 of 4

Thread: Is this the fastest way?

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    I am just wondering this because i use code similar to this pretty often. I wonder if there is a faster way to do this. Usually this is okay, but sometimes, instead of a text box, it loops thru 1000 or more strings in a variable array, and is a bit slow.

    ------------------------------------------------------
    Command1_Click
    intLength = Len(Text2.Text)
    intLength2 = Len(Text1.Text)

    If intLength > intLength2 Then Exit Sub
    intDifference = intLength2 - intLength

    For intNumTimes = 0 To intDifference
    strPart = Mid(Text1.Text, intNumTimes + 1, intLength2)
    If strPart = Text2.Text Then
    MsgBox("String Found")
    Exit Sub
    End If
    Next intLoop

    MsgBox("String Not Found")
    End Sub
    --------------------------------------------------------
    Any thoughts?


  2. #2

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    oh, in case it isn't obvious, the user types text in textbox 2 and clicks command 1.

    Then the app. looks for a match of the text in textbox 2 in textbox1.



  3. #3
    New Member
    Join Date
    Aug 2000
    Location
    Landskrona, Sweden
    Posts
    7
    I think that this would be faster...

    Command1_Click
    if instr(Text1.Text, Text2.Text) > 0 then
    MsgBox ("String Found")
    else
    MsgBox ("String Not Found")
    end if
    End Sub

  4. #4

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    That is exactly the little diddy i was driving at. I knew it existed.

    Well, I have a lot of programs to update now, so catcha later.


    btw, thanks.

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