By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,627 Members | 2,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,627 IT Pros & Developers. It's quick & easy.

How do I convert a date into a serial number

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
Daniel,

dim myDateAsLong as long = now.ticks

I hope this helps,

Cor
Nov 21 '05 #3

P: n/a
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

P: n/a
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.