3 Replies - 506 Views - Last Post: 07 June 2012 - 11:30 AM Rate Topic: -----

#1 frost-tien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 07-June 12

How to write a loop that only lets the user only click a button 10x

Posted 07 June 2012 - 11:16 AM

So basically i need to make a loop that only lets the user click it ten times then gives the answer to them.
i was gonna use a DO loop that looks like this so far.
Dim counter as integer
counter = 0 
Do until counter = 10 

loop



and after that i'm kinda lost on what to do, i know that its needs to be if you click btnenter 10 times give the right answer and then your done. Hell i could be even doing it wrong i don't know for me it just seems that the Do loop was easier to use im up for any other suggestion that anyone has.

i'm using VS 2010 vb.net for this for a little info

Is This A Good Question/Topic? 0
  • +

Replies To: How to write a loop that only lets the user only click a button 10x

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: How to write a loop that only lets the user only click a button 10x

Posted 07 June 2012 - 11:19 AM

You don't really need a loop at all.

Just have an Integer field called counter set to 0. Each time you click the button, in the event handler, increment the counter variable and check if it is now 10. If it is, show the answer.
Was This Post Helpful? 1
  • +
  • -

#3 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: How to write a loop that only lets the user only click a button 10x

Posted 07 June 2012 - 11:23 AM

Just use an If statement inside the loop to check if the variable counter equals 10, then disable the button and show the answer. You have to increment the variable counter by 1 at the end of a loop. You're missing that part in your code.

EDIT: Actually Ryano121 is right. Do it his way.

This post has been edited by nK0de: 07 June 2012 - 11:25 AM

Was This Post Helpful? 1
  • +
  • -

#4 frost-tien  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 07-June 12

Re: How to write a loop that only lets the user only click a button 10x

Posted 07 June 2012 - 11:30 AM

ok thank you for your guys help both ideas where very helpful, din't think of disabling the button after clicking it 10 times thanks nKOde
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1