Convert Numeric Format to Time Format

  • Thread starter Thread starter WorldIsEnding
  • Start date Start date
W

WorldIsEnding

Hey,

Im having trouble with converting a Numeric value (such as a single
digit number like 1 or 5) into a time format.

I need to convert a number entered into a variable into Hours on the
first form, then from Hours into Seconds when a second form is loaded.

Anyone got any ideas? If you need more info, let me know and ill post
a code snippet or something.

Cheers.
 
Doh, i was supposed to put "Hours into Minutes when a second form is
loaded" Not hours into seconds >.<
 
Hi,

dim mydate as datetime = new datetime(yy,MM,dd,hh,mm,ss)

I hope this helps,

Cor
 
Umm.. can i ask - where is that meant to go within my code? And how
does it achieve what i need it to do?
 
Hey,

Im having trouble with converting a Numeric value (such as a single
digit number like 1 or 5) into a time format.

I need to convert a number entered into a variable into Hours on the
first form, then from Hours into Seconds when a second form is loaded.

Anyone got any ideas? If you need more info, let me know and ill post
a code snippet or something.

Cheers.

You can create a TimeSpan value from the hours:

Dim time As TimeSpan = New TimeSpan(hours, 0, 0)

The TimeSpan structure has properties you can use to get components of
the time, like Hours, Minutes and Seconds. It also has properties to
express the entire time span in units, like TotalHours, TotalMinutes and
TotalSeconds.

Example:

Dim hours As Integer = 4
Dim time As TimeSpan = New TimeSpan(hours, 0, 0)
Dim minutes As Double = time.GetTotalMinutes

The minutes variable now contains 240.0.
 
Hello Göran,

In VB.Net I believe the Timeserial/Dateserial function is still there. You
can probably use it too


-- You can do anything with a little bit of 'magination.

-- I've been programming so long, my brain is now software.
 
Back
Top