|
-
Apr 21st, 2009, 04:05 AM
#1
Thread Starter
Junior Member
[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?
-
Apr 21st, 2009, 05:18 AM
#2
Re: Line Input doesn't like the "Like" operator?
you could use instr
vb Code:
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
-
Apr 21st, 2009, 05:20 AM
#3
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$.
-
Apr 21st, 2009, 05:37 AM
#4
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 * *"
-
Apr 21st, 2009, 04:57 PM
#5
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|