473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

simple counter question

I have a program that is in need of keeping track of how many times the
command button has been clicked . I have a dollar amount totaled in a label,
every time the user clicks the command button represents 1 customers order.
I want to find the average per customer for daily sales. Is there a simple
way to just keep track of the number of times a command button has been
clicked?
Nov 21 '05 #1
6 1650
Is this a program you have created ? Or do you want to keep track of clicks
on a third party software?
"Rodger Arndt" <ro***************@hotmail.com> wrote in message
news:ef********************@seanet.com...
I have a program that is in need of keeping track of how many times the
command button has been clicked . I have a dollar amount totaled in a label, every time the user clicks the command button represents 1 customers order. I want to find the average per customer for daily sales. Is there a simple
way to just keep track of the number of times a command button has been
clicked?

Nov 21 '05 #2
no, all within the program, either a do/while or a for next. whatever. I am
displaying the average on the form in a label right under the total sales
for the day.
Nov 21 '05 #3
You could just say:

Dim intClicked As Integer 'Public declaration

Behind the Button1 click event:

intClicked +=1
Label1.Text = "$" & intClicked

The above will be fine unless you close the form then 'intClicked' will be
set to zero.

-------------------------------------------------------------------
Another way is to hold the value in a text file

Do the same as above, but in the Form Closing Event put this:

Dim sw As New IO.StreamWriter("C:\Clicked.txt", False) ' Don't Append
sw.WriteLine(intClicked)
sw.Flush()
sw.Close

-----------------------------------
To read the above back into the program:

Dim sr As New IO.StreamReader("C:\Clicked.txt")
intClicked = CInt(sr.ReadLine)
sr.Close
Label1.Text = "$" & intClicked

-----------------------------------------------------------

Another way you could do it is store it in the registry (form closing event):

Imports Microsoft.Win32 ' Import used for registry

Dim reg As RegistryKey
reg = Registry.CurrentUser.OpenSubKey("Software\MyKey", True) 'True = Write
reg.SetValue("TimesClicled", intClicked)
reg.Close

-----------------------------------------------

To get the value from the registry:

Dim intTemp As Integer
Dim reg As RegistryKey
reg = Registry.CurrentUser.OpenSubKey("Software\MyKey", False) 'Read Only
intTemp = reg.GetValue("TimesClicled")
If (Not intTemp Is Nothing) Then
TimesClicled = intTemp
reg.Close
Label1.Text = "$" & TimesClicled

The above has been typed straight into here & not copied from the VS IDE.

I hope this has helped

"Rodger Arndt" wrote:
I have a program that is in need of keeping track of how many times the
command button has been clicked . I have a dollar amount totaled in a label,
every time the user clicks the command button represents 1 customers order.
I want to find the average per customer for daily sales. Is there a simple
way to just keep track of the number of times a command button has been
clicked?

Nov 21 '05 #4
this is what I was looking for.

intClicked +=1
Label1.Text = "$" & intClicked
Thank you
Nov 21 '05 #5
What if the user quit your program before end of the day or break out then
how do you get back your intClicked value?

chanmm
"Rodger Arndt" <ro***************@hotmail.com> wrote in message
news:vv********************@seanet.com...
this is what I was looking for.

intClicked +=1
Label1.Text = "$" & intClicked
Thank you

Nov 21 '05 #6
chanmmn,

See my previous post on this thread & it will tell you how to do it

"chanmmn" wrote:
What if the user quit your program before end of the day or break out then
how do you get back your intClicked value?

chanmm
"Rodger Arndt" <ro***************@hotmail.com> wrote in message
news:vv********************@seanet.com...
this is what I was looking for.

intClicked +=1
Label1.Text = "$" & intClicked
Thank you


Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Paul Rubin | last post by:
I'd like to have a function (or other callable object) that returns 0, 1, 2, etc. on repeated calls. That is: print f() # prints 0 print f() # prints 1 print f() # prints 2 # etc. ...
6
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that,...
7
by: dan | last post by:
hey peeps, i am completely new at c++ and i need some help with an assignment. it is basically about file i/o with fstreams. i understand how to open a file with fstream, but how would you read,...
2
by: jagivens | last post by:
Hi, I have two identical programs that encrypt characters. One is written in C++, and it works, but the other one is written in C, and it does not work. I have copied the code below. There is...
7
by: JellyON | last post by:
Hi. Is there a way to delay a call to a page counter (ie. call to a server script from an IMG tag) for the purpose to not lock the page loading awaiting counter be displayed. Maybe a...
32
by: someone else | last post by:
hi all I'm a newbie to this group. my apologies if I break any rules. I've wrote a simple program to find the first 1,000,000 primes, and to find all primes within any range (up to 200 *...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
11
by: James R. Davis | last post by:
Yes, a newbie here. Though I am making progress, slowly, I am also getting more and more confused. With ASP, when I wanted to do something as trivial as updating a visitor counter, I...
11
by: tony19760619 | last post by:
To make this work on a single page you will need to create/modify 4 files. So here goes... Create a file called counter.php and put following code in it: <?php //Counter $count_my_page =...
9
by: Pygmalion | last post by:
I have found dozen of useful PHP counters on the web. However, nobody is working for my web pages, since administrator does not want to enable the possibility that PHP could be called from HTML. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.