By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,377 Members | 471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,377 IT Pros & Developers. It's quick & easy.

InStr Return type

P: 6
A textual comparison starting at position 4. Returns 6.
MyPos = Instr(4, SearchString, SearchChar, 1)


' A binary comparison starting at position 1. Returns 9.
MyPos = Instr(1, SearchString, SearchChar, 0)

' Comparison is binary by default (last argument is omitted).
MyPos = Instr(SearchString, SearchChar) ' Returns 9.

MyPos = Instr(1, SearchString, "W") ' Returns 0.

Can anyone tell me how this is returning 6 and 9.
Dec 15 '06 #1
Share this Question
Share on Google+
2 Replies

100+
P: 1,646
A textual comparison starting at position 4. Returns 6.
MyPos = Instr(4, SearchString, SearchChar, 1)


' A binary comparison starting at position 1. Returns 9.
MyPos = Instr(1, SearchString, SearchChar, 0)

' Comparison is binary by default (last argument is omitted).
MyPos = Instr(SearchString, SearchChar) ' Returns 9.

MyPos = Instr(1, SearchString, "W") ' Returns 0.

Can anyone tell me how this is returning 6 and 9.
Hi
When you use instr in textual comparison with a 1 as the last argument, it is not case sensitive so it will find upper or lowercase matches, the binary compare will only find the same case as the search character.

so in textual comparison looking for 'P' it will find both 'p' and 'P'
in binary comparison it will only find 'P'
Dec 15 '06 #2

P: 6
Hi
When you use instr in textual comparison with a 1 as the last argument, it is not case sensitive so it will find upper or lowercase matches, the binary compare will only find the same case as the search character.

so in textual comparison looking for 'P' it will find both 'p' and 'P'
in binary comparison it will only find 'P'

Thanks mam. now i m clear with the concept.
Dec 18 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.