AllExperts > Experts 
Search      

Visual Basic

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Visual Basic Answers
Question Library

Ask a question about Visual Basic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Frank G. Dahncke
Expertise
I can answer most questions realating to real-world application programming in Visual Basic .NET (including SQL-Server 7.0 and up). I NO LONGER ANSWER VB6 QUESTIONS. My speciality is GUI/frontend work and API calls. I do not know about Internet, games or graphics programming, just the bread-and-butter stuff. I answer questions in German as well.

Experience
Experience: I have been programming BASIC applications professionally for 22 years now (2007), having done most any application type from multimedia CBT to telephone directories to database frontends. Organizations: RA-MICRO Software GmbH
 
   

You are here:  Experts > Computing/Technology > Basic > Visual Basic > Count click events

Topic: Visual Basic



Expert: Frank G. Dahncke
Date: 6/23/2008
Subject: Count click events

Question
I am just starting off learning VB 2008.  I am wanting to count the number of times a button is clicked by the user.  I can't seem to find any information about how I can refer to the click event and then count the times a user clicks it. Any pointers or help you can shed to help me on my way would be appreciated. Thanks

Answer
No problem. First, at the Module level, declare an integer variable as counter, then increment it in the Click event. Hint: to get to the Click event, just double-click the button in design mode. Then, your code should look like this:

Public Class Form1

   Dim miCounter As Integer = 0

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       miCounter += 1
   End Sub
End Class


Yours,

Frank

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.