How do I convert a date into a serial number

  • Thread starter Thread starter Daniel Kaseman
  • Start date Start date
D

Daniel Kaseman

How do I convert a date into a serial number?

(I'm trying to enter a FROM date and a TO date, then make my PROGRESS BAR
show how close I am to the TO date.) get it?

I know that MS Excel converts Dates into serial numbers, but I can't figure
out how to do it with VB.Net.

Please help, thanks.
 
Daniel,

You could use VB's DateDiff function to find the number of time intervals
between the 2 dates. The interval can be days, hours, etc.

You could then use the time intervals to drive the progress bar.

Kerry Moorman
 
Daniel,

dim myDateAsLong as long = now.ticks

I hope this helps,

Cor
 
This is what I done:

1) Start a new Windows application
2) Add a timer, a progressbar & a button to the form
3) Declarations:

Dim dtFrom As Date = #2/3/2005# ' Just a date I picked randomly

Dim dtTo As Date = DateTime.Now

Dim intDays As Integer

4) Double-click the button & add the following code:

intDays = Microsoft.VisualBasic.DateDiff(DateInterval.Day, dtFrom, dtTo)

'MessageBox.Show(intDays)

With ProgressBar1

.Minimum = 1

.Maximum = intDays

End With

Timer1.Enabled = True

Timer1.Interval = 200

5) Double-click the timer & add the following code:

If ProgressBar1.Value < intDays Then

ProgressBar1.Value += 1

Else

ProgressBar1.Value = intDays

Timer1.Enabled = False

End If

6) Run the project.

There are 76 days between the two dates at the time of posting

I hope this helped

Crouchie1998
BA (HONS) MCP MCSE
 
Combining TimeSpan Class with Cor's Ticks is a convienent way to convert to
Days, hours, min, sec, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top