I am writing a quick Linux desktop app and seemingly strange things are happening with For...Next loops.
For example, the following code is supposed to detect how many times "1" occurs in a string:
dim intTestCount as integer For intIndex as integer = 1 to 256 if strData.Mid(intIndex, 1) = "1" then intTestCount = intTestCount + 1 end if next
intTestCount then equals 135 which is impossible since (a) the loop can only increment
intTestCount to a max of 256 and (b) the
strData.len = 256 !
And another thing. If intIndex in a loop (not the one above) is defined as uint8, with the range being from 0 to 255, the loop overflows with a n exception when it reaches 255. That is to say there seems not to be the full 256 numbers in the range!
I usually use Do loops with manual counters not For Next loops because very explicit code is cheaper to maintain in the long run. However on this occasion I wanted the code to be brief but have spent a lot of time wrestling with problems with the For Next control structure itself.
I will go back to Do loops but I want to find out if it is just my dev environment or does anyone else ever see this in the Linux IDE ?