Jump to content

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

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
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

How to get your question answered on this forum!

Link to comment
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

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...