469,282 Members | 1,743 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

How do I convert a date into a serial number

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.
Nov 21 '05 #1
4 14209
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 Kaseman" wrote:
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.

Nov 21 '05 #2
Daniel,

dim myDateAsLong as long = now.ticks

I hope this helps,

Cor
Nov 21 '05 #3
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

Nov 21 '05 #4
Combining TimeSpan Class with Cor's Ticks is a convienent way to convert to
Days, hours, min, sec, etc.

"Cor Ligthert" wrote:
Daniel,

dim myDateAsLong as long = now.ticks

I hope this helps,

Cor

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Lauren Quantrell | last post: by
3 posts views Thread by Stewart Allen | last post: by
3 posts views Thread by jerry.ranch | last post: by
6 posts views Thread by Trekmp | last post: by
4 posts views Thread by Peter | last post: by
17 posts views Thread by Terry Jolly | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.