Check string for chr(10)

J

John W

I'm import some text files that contain returns -- chr(10). I'm parsing the
information using VBA's InStr. What is the proper way to check and see if
the next value in a string is chr(10). Everything I try is not working.

For example
If Left(mystring,instr(mystring,"*")-1) <> chr(10) then
This does not work. Please help!
Thank you!
 
D

Duane Hookom

Your use of Left() may return multiple characters. Also, this will error if
"*" is not found in the string. If you want to check the character following
the "*" try something like:
If Mid(mystring, Instr(mystring & "* ", "*") +1,1) = Chr(10) Then
 
J

Jeff Boyce

John

The code snippet you posted tells Access to check for an asterisk, back up
one place, then take the leftmost characters from beginning to that
location, and compare to chr(10). I can imagine a number of ways this could
"not work".

What does "not work" mean to you?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John W

You are correct about looking for an asterisk - this is always my delimiter.
I'll try the Mid statement and see what happens.

Thanks for the advice!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top