?
Solved

How to reset a counter if a new day occurs.

Posted on 2013-01-24
3
Medium Priority
?
340 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 1200 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

762 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