# Do.. Until.. If.. Then.. Count Problems [Solved]

## Recommended Posts

I am trying to figure out why my count is going to 2 after this Do... Until...

```Local \$vTopCount = 1
Local \$vBottomCount = 1
Local \$vFindStart = 0

DO

MsgBox(0,"",\$vTopCount)

If \$vFindStart = 'X' Then
\$vTopCount = \$vTopCount + 1
\$vBottomCount = \$vBottomCount + 1
EndIf

Until \$vFindStart = 0

MsgBox(0,"",\$vTopCount)```

I would expect it to stay at one. :/ What am I missing here.

Edited by SkysLastChance

Life's simple. You make choices and you don't look back.

##### Share on other sites
• Moderators

Take a look at this and you should see why (no pun intended):

```Local \$vTopCount = 1
Local \$vBottomCount = 1
Local \$vFindStart = "y"

DO

MsgBox(0,"",\$vTopCount)

If \$vFindStart = 'X' Then
\$vTopCount = \$vTopCount + 1
\$vBottomCount = \$vBottomCount + 1
EndIf

Until \$vFindStart = 0

MsgBox(0,"",\$vTopCount)```

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

##### Share on other sites

Try this too :

```Local \$vFindStart = 0
MsgBox (\$MB_SYSTEMMODAL,"",\$vFindStart = 'X')```

Comparing number and string are rarely a good idea

Not much of a signature but working on it...

Spoiler

##### Share on other sites

The light bulb came on finally.

Thank you!

```Local \$vTopCount = 1
Local \$vFindStart = 0

Do

MsgBox(0,"",\$vTopCount)

If \$vFindStart <> "" Then ;Will loop if anything is in cell
\$vTopCount = \$vTopCount + 1
EndIf

MsgBox(0,"",\$vTopCount)

Until \$vFindStart = 0```

Edit:

```Local \$vTopCount = 1
Local \$vFindStart = "X"

Do

MsgBox(0,"",\$vTopCount)

If \$vFindStart <> "" Then ;Will loop if anything is in cell
\$vTopCount = \$vTopCount + 1
EndIf

MsgBox(0,"",\$vTopCount)

Until \$vTopCount = 2```

Edited by SkysLastChance

Life's simple. You make choices and you don't look back.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...