Adjusting Arrays

I would like to be able to take an array and apply certain rules to only certain parts of it. For example: I have an array with 450 items and I want to change values 1-23 and 55-70 to “S”. Any suggestions on this?

It depends…will the 1-23 and 55-70 values be fixed, meaning always the same elements being changed? If so, a simple loop would work, for 1-23 for example:

x=0 do until x=24 x=x+1 arrayname(x)="S" loop

Use this actually:

x=0 do until x=23 x=x+1 arrayname(x)="S" loop

Yes that will work, thanks!

I would use a For/Next loop

[code]For x As Integer = 1 To 23
arrayname(x) = “S”
Next

For x As Integer = 55 To 70
arrayname(x) = “S”
Next
[/code]

From my limited testing and reading, i’ve seen that For…Next tends to bring a bit of a performance hit, but Wayne’s will work too. :slight_smile:

Actually, a test with microseconds shows exactly the same execution time between do-until, for-next and while-wend… Could be because Xojo uses the same underlying routine…