Solved

How to reset a counter if a new day occurs.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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 …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

20 Experts available now in Live!

Get 1:1 Help Now