Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using InStr with non-printable characters

Status
Not open for further replies.

LiamE

Programmer
Mar 16, 2004
5
GB
Hello,

I have a database field containing text that is split using the "Horizontal tab" character, i.e. ASCII code 9 (vbTab).

My Crystal Formula (Basic syntax) needs to detect this using InStr but this does not appear to find it.

e.g. using
Code:
iChar = InStr(iStartChar, strToSearch, Chr(9), 1)
Does not find it.

I have also tried using binary search (i.e. last parameter as a 0), or searching for CStr(Chr(9)) to no avail.

Does anyone have any suggestions how I can get this to work?

Thanks

Liam
 
I just tested this and got the same results with a string like:

"I went on my way (keyboard tab) to the store."

If I counted the spaces that the tab used, and changed the formula to:

instr(3, {@string}," ") //used the "3" just to replicate your approach

It returned the correct result.

If I changed the string to:

"I went on my way"+chr(9)+"to the store."

I also got the correct result, but the string displayed as:

"I went on my wayto the store."

Not sure why...

-LB
 
Hi lbass,

Thanks for your reply.

I have the same problem with the display of the string simply removing the Chr(9)! Not only does it not detect the Chr(9) using InStr, but it misses it out when displaying it and doesn't even display a space instead.

Since I am fortunate enough to still be able to change the design of my software, I have decided to go back to plan (a) which is using a printable character (backslash) as a separator instead.

Thanks anyway for your input;

Liam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top