# Translate 'while' loop to 'for' loop

**URL:** <https://forum.kirupa.com/t/translate-while-loop-to-for-loop/116083>\
**Category:** Uncategorized\
**Created:** [July 14, 2004, 2:05pm UTC](https://forum.kirupa.com/t/translate-while-loop-to-for-loop/116083 "2004-07-14T14:05:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fumeng](https://avatars.discourse-cdn.com/v4/letter/f/a9adbd/32.png) [@fumeng](https://forum.kirupa.com/u/fumeng)\
**Post date:** [July 14, 2004, 2:05pm UTC](https://forum.kirupa.com/t/translate-while-loop-to-for-loop/116083/1 "2004-07-14T14:05:07Z")

</div>

hi.

i’m create a grid-like structure and am trying to translate my old loop:

```auto

while (dayCount <= lastDay) // creates 30 text fields

```

to a ‘for’ loop where I can increment the position of each duplicated text field by i \* a specified width.

the thing is that i can’t figure out how to do that with my while loop. but i can do it with a ‘for’ loop. that’s why i’m trying to change it.

earlier in my code i use this ‘for’ loop to lay out the row above where i want to start…

```auto

for(var i:Number = 0; i < numCols; i++){
     _root.createTextField("dayHeadings" + i, i, indColWidth*i, startSecRowYPos, indColWidth, colHeight);
     _root["dayHeadings"+i].border = true;
     _root["dayHeadings"+i].text = dayHeadings*;
}

```

anyone have any ideas?

thanks to anyone for helping out. fumeng.
