Link to home
Start Free TrialLog in
Avatar of Michael Paravicini
Michael ParaviciniFlag for Chile

asked on

InStr looking for spaces does not give the expected result

I am getting old but somehow the following code does not yield the desired result:

xName = "Steven Murray Thomas"
MsgBox InStr(1,xName," ")

gives zero and not the expected 7. Any help why?
Thank you so much Michael
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

No. It works fine for me - with a direct copy-paste - returns 7.
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or simply put this statement and see what number it returns. If it doesn't return 32, that means the white space is not the space character.

MsgBox Asc(Mid(xName, 7, 1))

Open in new window

Or just delete your old code and copy-paste your own code here at top … that was what I did.
Avatar of Michael Paravicini

ASKER

Thank you so much to all of you. It was indeed as Jim said. It as not a space but a ASCI 160 - I now simply replaced it with CHR(32) and it works fine! Thank you.. Cheers Michael