Instr function 
Author Message
 Instr function

as far as I understand, it still counts the final result based on the
first characterv of the string, not the first character you search

how about using  mid(R.sBuf,2) so that you are only searching the part
you want; then you will get the 4 you desired.

Quote:

>I am using the Instr function (with binary compare)in a proceedure:

>iLeft = InStr(i, R.sBuf, "<", 0)

>where:
>R.sBuf = <F0><End Sub><F0>Safety belts required for driver and all passen
>i = 2

>After the line is run, iLeft is equal to 5. I expected iLeft to be 4.

-------------------
Richard Killey

Visit www.comeandread.com/access for some Access 97 tips.



Mon, 08 Jul 2002 03:00:00 GMT  
 Instr function
I am using the Instr function (with binary compare)in a proceedure:

iLeft = InStr(i, R.sBuf, "<", 0)

where:
R.sBuf = <F0><End Sub><F0>Safety belts required for driver and all passen
i = 2

After the line is run, iLeft is equal to 5. I expected iLeft to be 4.

If the search starts with the second character: 'F', doesn't it call this
the 'first' position (1) and starts it search from there? This should find
the '<' at the 4th position from the start.

Another run through this line with i = 1 produced an iLeft = 1, which I felt
was correct.

The help files give some examples, but one of these is wrong I think:

Dim SearchString, SearchChar, MyPos
SearchString ="XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".

' A textual comparison starting at position 4. Returns 6.
MyPos = Instr(4, SearchString, SearchChar, 1)
'I thought this would be a 3, the lower-case 'p' (textual compare)

What is going on here?

Thank you,
Rusty



Mon, 08 Jul 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. InStr Function Help

2. Bug in INSTR function

3. InStr Function does not work if start position is skipped

4. Instr Function Explanation Anyone ???

5. INSTR function flawed (QB45)

6. INSTR function NOT flawed (QB45)

7. Proble with INSTR function in SQL statement

8. Using the Instr function

9. Multiple Instr function Question ?

10. Usage of InStr() function

11. INSTR() FUNCTION: need help

12. Instr function

 

 
Powered by phpBB® Forum Software