Results 1 to 5 of 5

Thread: [RESOLVED] Line Input doesn't like the "Like" operator?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    22

    Resolved [RESOLVED] Line Input doesn't like the "Like" operator?

    Hey, I have a real annoying problem. Ha ha.
    I'm trying to read a text document and search for a line in this format:
    Code:
    #CLIP {NAME} {LOOP}
    But when I use the code:
    Code:
    If strBuffer Like "#CLIP * *" Then
    It will never find the line in the text document.
    I have tried changing lots of lines of code, but nothing works...
    It will work if I change it to:
    Code:
    If strBuffer = "#CLIP TEST True" Then
    But that isn't what I want...
    Does anyone know what my problem is?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Line Input doesn't like the "Like" operator?

    you could use instr

    vb Code:
    1. if instr(strbuffer, "#CLIP") > 0 then   ' found

    # is special in LIKE and has to be escaped, this would work, using wildcard to replace #
    If strbuffer Like "?CLIP * *" Then
    Last edited by westconn1; Apr 21st, 2009 at 05:25 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Line Input doesn't like the "Like" operator?

    I think you may need to use Regular expression for that. If you only want to find lines that start with #CLIP then you can try LEFT$.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Line Input doesn't like the "Like" operator?

    With Like operator, # denotes a digit. Your line text contains litteral character "#" not a digit (0-9).
    Change it to:
    ... Like "[#]CLIP * *"
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    22

    Re: Line Input doesn't like the "Like" operator?

    Thanks heaps.
    I had no idea that it represented that.
    That also answers my other question. Ha ha.
    Thanks guys.

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