473,406 Members | 2,954 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,406 software developers and data experts.

Lifetime Counter that Doesn't Reset

I am writting a program in which I want to have a lifetime counter that doesn't reset when I close and reopen the program.

The program is designed to take input and print it into a work order type form and I want there to be a counter for the work order number that continually increases by 1 everytime the form is made no matter if the program is closed inbetween uses.

atetz785
Jul 26 '07 #1
6 1739
You're going to have to save the 'Counter' information outside of the application. The easiest way is probably a text file, that is read in as part of the application initialisation.
Jul 26 '07 #2
MikeTheBike
639 Expert 512MB
I am writting a program in which I want to have a lifetime counter that doesn't reset when I close and reopen the program.

The program is designed to take input and print it into a work order type form and I want there to be a counter for the work order number that continually increases by 1 everytime the form is made no matter if the program is closed inbetween uses.

atetz785
If you are in Excel, then save the number to a hidden sheet.

Otherwise the options I can think of are

Retrieve/save to/from a database file
Retrieve/save to/from other external (text?) file
or save in the registry (don't ask me how - I've successfully avoided such things, so far... ).


MTB
Jul 26 '07 #3
When I try saving the counter to a hidden sheet, Visual Basic doesn't find the worksheet to select the cell. Is there a different way to select the cell on a hidden sheet other than the code below or is it just not possible to select hidden sheets.

Sheets("Sheet1").Select
Range("D8").Select
Jul 26 '07 #4
MikeTheBike
639 Expert 512MB
When I try saving the counter to a hidden sheet, Visual Basic doesn't find the worksheet to select the cell. Is there a different way to select the cell on a hidden sheet other than the code below or is it just not possible to select hidden sheets.

Sheets("Sheet1").Select
Range("D8").Select
What happens?

Don't Select the sheet just read/write to it ie

CurrentNo=Sheets("Sheet1").Range("D8") or whatever
and
Sheets("Sheet1").Range("D8")= Current No +1

Tip
I would give the cell a Name (Say Counter) and refer to that ie

CurrentNo = Range("Counter")

Range("Counter") = CurrentNo+1

HTH


MTB
Jul 26 '07 #5
fplesco
82
Hi atetz785 -

I'd like to assume that you dont have problems with the codes you want for your program. I mean, that your program works to what really is intended and you just want to simply save the counter that you dont want to reset. This might help you.

Try using the system registry like this.

Getting values to the registry
[code]
Counter = GetSetting(APP.EXENAME,"COUNTERS","TASK COUNT")
[code]

Saving values to the registry
[code]
SaveSetting APP.EXENAME,"COUNTERS","TASK COUNT", Counter + 1
[code]

Counter must be a GLOBAL variable.

Hope this would help.

Have a nice day.
Jul 27 '07 #6
MikeTheBike
639 Expert 512MB
Hi atetz785 -

I'd like to assume that you dont have problems with the codes you want for your program. I mean, that your program works to what really is intended and you just want to simply save the counter that you dont want to reset. This might help you.

Try using the system registry like this.

Getting values to the registry
[code]
Counter = GetSetting(APP.EXENAME,"COUNTERS","TASK COUNT")
[code]

Saving values to the registry
[code]
SaveSetting APP.EXENAME,"COUNTERS","TASK COUNT", Counter + 1
[code]

Counter must be a GLOBAL variable.

Hope this would help.

Have a nice day.
Hi fplesco

Although I did suggest this in a previous post (but never used), on reflection I think this would be a bad idea if more than one person use the spreadsheet/program on different machines, as they all would have there own counter value??


MTB
Jul 27 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Who.Really.Really.Cares | last post by:
Hi! I guess this must be a FAQ but I'll give it a try. I've searched the web and usenet archive and found only negative answers. But most of them were dated like 3-4 years back. Hasn't anything...
1
by: Andrea DD | last post by:
I've MS - Access 97 database installed, and I've defined a datatype counter for a field, but when I delete all the records the counter is not reset. How can I do to reset the datatype counter...
0
by: Earl Anderson | last post by:
KB Article Q140908 provided the following function to create an Auto Incrementing Counter: Function Next_Custom_Counter () On Error GoTo Next_Custom_Counter_Err Dim MyDB As Database Dim...
6
by: fantum | last post by:
I have created a small activex dll to do a background task on my web server. I fire it off with a set myjob = server.createobject(myactivex) and it runs. I do not do a set myjob = nothing and so...
0
by: Trevor L. | last post by:
I decide to put a custom Hit Counter on my page (below). Then I won't be reliant on the standard FrontPage one which uses webbots. It is called by <b>Hit Counter: </b><!--#include...
5
by: jasonchan | last post by:
How would you set up a counter in javascript that goes from 5 to 0 This is what i have so far and it is not displaying in the div container "counter" for some reason... <!DOCTYPE html PUBLIC...
3
blackstormdragon
by: blackstormdragon | last post by:
Here were our instructions: "My mother always took a little red counter to the grocery store. The counter was used to keep tally of the amount of money she would have spent so far on that visit to...
30
by: Paul W Smith | last post by:
I have written a hit counter, which I believe counts the times my page is hit by a user for each unique session by the user. The relevant part of my code is below: If...
5
by: Juha Nieminen | last post by:
Let's assume we have a class like this: //--------------------------------------------------------- #include <iostream> class MyClass { public: MyClass() { std::cout << "constructor\n"; }...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.