user2844908
user2844908

Reputation: 13

Visual Basic: Increasing integer every 3 clicks

So my question is pretty much what the title says: how do I get a certain integer to increase by 1 for every three clicks of a button? For example, let's say the integer is 900. I click button1 once, then again, then again, and on the third click the integer changes to 901. How can this be accomplished?

Thanks in advance.

Upvotes: 0

Views: 990

Answers (2)

Denmark
Denmark

Reputation: 538

Try this maybe this could help or give you idea

Dim click = 0
Dim num = 900

if (click % 3 = 0)
   num+=1
else
 click+=1
end if

Upvotes: 0

Guffa
Guffa

Reputation: 700322

Use a counter that is actually three times larger behind the scene. Start at 2700 instead of 900, and increase the value by one for each click.

When you want to display the value that increases every third click, you divide the counter by three:

displayValue = counter \ 3

Upvotes: 1

Related Questions