Solved

How to reset a counter if a new day occurs.

Posted on 2013-01-24
3
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 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