Avatar of Michael Paravicini
Michael Paravicini
Flag 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
Microsoft AccessVBA

Avatar of undefined
Last Comment
Michael Paravicini

8/22/2022 - Mon
Gustav Brock

No. It works fine for me - with a direct copy-paste - returns 7.
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Dale Fye

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Subodh Tiwari (Neeraj)

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

Gustav Brock

Or just delete your old code and copy-paste your own code here at top … that was what I did.
Your help has saved me hundreds of hours of internet surfing.
fblack61
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