Check string for chr(10)

  • Thread starter Thread starter John W
  • Start date Start date
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!
 
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
 
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
 
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!!!
 
Back
Top