Solved

How to reset a counter if a new day occurs.

Posted on 2013-01-24
3
311 Views
Last Modified: 2013-02-13
I need to check dates on my PC so that each new day I can reset a counter (IntActualPartCounter). I have the following line of  code that creates a barcode and calculates the Julian day of the year.

 strbarcode = "G" & _partfile.ThermalPrinterProgramCode & UserShift & (DateDiff("d", CDate("01/01/" + Format(Year(Now), "0000")), Now) + 1).ToString.PadLeft(3, "0"c) _
                      & Now.Year.ToString.Substring(2) & Format(newRuntimeClass.intActualPartCounter, "000")

How can I do this?
0
Comment
Question by:cmdolcet
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 300 total points
ID: 38815905
I would do it with a user setting in the application configuration file.

First, define a date User (not Application) setting in the Settings tab of the Project's Properties window. Give it a value for the day where you start using the mechanism.

When required by the application, you can read the setting with code similar to the following:

My.Settings.YourSettingName

Simply compare the returned value with the current date. If the date has changed, reset your counter and change the setting to the current date, not forgetting to save the change:

My.Settings.YourSettingName = Date.Today
My.Settings.Save()

You will be ready for the following day.
0
 

Author Comment

by:cmdolcet
ID: 38839247
James Burger...... I will not know when the user first uses the system because they may install it on a test PC for review then bring the PC out to the floor. So how would it work then?
0
 
LVL 40
ID: 38885580
Enter a dummy value for the startup then, something like 1900-01-01.

The application would check for that value at launch. If it is still there, you would ask the user if he is testing. If so, do not reset it. Otherwise, assume that they are starting the system for the first time and set the value to the current date.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now