Solved

How to reset a counter if a new day occurs.

Posted on 2013-01-24
3
321 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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 …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 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