View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default VBA mid() function

No, you didn't miss anything... I did. Sorry for the confusion, but
apparently I misread the original post and then made my comment based on my
misreading.

--
Rick (MVP - Excel)


"Charlie" wrote in message
...
Did I miss something? On the first iteration L would equal 1. The loop
is
from 1 to 10 -- the STRING started at zero ("0123...")


"Rick Rothstein" wrote:

I'm not "picking" on your Charlie, it's just I needed to attach this note
to
either you message or Peter T's message... I chose yours.

Both you and Peter made the same suggestion (to change the second L to a
one)... my question to the both of you is...

How does that explain the OP's statement "The above
code returns the correct value only on the 1st iteration"?

It would seem that changing the second L to a one would make it so the
first
iteration would fail, not succeed.

--
Rick (MVP - Excel)


"Charlie" wrote in message
...
Debug.Print Mid$(S, L, 1)

Use a 1 not "L"

"vello" wrote:

Using XP & Excel2002 to find a string in another string, gets me weird
results:
Dim S As String
Dim L As Long

S = "0123456789"
For L = 1 To 10
Debug.Print Mid$(S, L, L)
Next

The above code returns the correct value only on the 1st iteration.
Thereafter the Mid$ keeps growing.

Is there an API procedure to accomplish this? Can't seem to find it.


.