COLON chr(58) and INSTR behavior in Access 2000 VBA

  • Thread starter Thread starter Timo
  • Start date Start date
T

Timo

I'm trying to parse a plain text string containing time values having
various irregularities (e.g. "12:30 P.M.", "4 AM", "5pm", "4:00 AM", "4 :00"
and so on). I need to grab the chunk to the left and right of the colon,
but I can't get InStr to correctly return the position of the colon in the
string. It always returns -1 as though the string did not contain a chr(58).
But I've confirmed that it does indeed contain this character. Is the colon
a reserved character that InStr cannot handle?
TIA
 
Timo said:
I'm trying to parse a plain text string containing time values having
various irregularities (e.g. "12:30 P.M.", "4 AM", "5pm", "4:00 AM", "4 :00"
and so on). I need to grab the chunk to the left and right of the colon,
but I can't get InStr to correctly return the position of the colon in the
string. It always returns -1 as though the string did not contain a chr(58).
But I've confirmed that it does indeed contain this character. Is the colon
a reserved character that InStr cannot handle?

I can not reproduce your problem (in AXP).

You say InStr is returning a -1?? I've never heard of that
happening, InStr either returns the position of the
substring or zero if it's not found.

There has got to be more going on than just what you've
described here. Are you sure you're using the built in
InStr function and not some user defined function with the
same name???
 
-----Original Message-----
I'm trying to parse a plain text string containing time values having
various irregularities (e.g. "12:30 P.M.", "4 AM", "5pm", "4:00 AM", "4 :00"
and so on). I need to grab the chunk to the left and right of the colon,
but I can't get InStr to correctly return the position of the colon in the
string. It always returns -1 as though the string did not contain a chr(58).
But I've confirmed that it does indeed contain this character. Is the colon
a reserved character that InStr cannot handle?
TIA
Darren is right on. Sounds like your instr function is
embedded in another boolean function and it is
returning -1 which means True. -1 = True, 0 = False
 
Back
Top