Converting Time to Single(Data Type)

edster001
09-11-2003, 06:30 AM
I would like to know if it is possible to convert time to Single. In Excel you can set a cell format to [h]:mm for times over 24hr's. and in another cell you set the format to generall and it will convert the time to Single. For example 39:30 gives a result of 1.645833333. Now in vb i can convert 1.645833333 back to 39:30 but not from 39:30 to 1.645833333. Here is some sample code that can convert the single to time format.(I cant get it to give me 39:30, instead it gives me 15:30, I have tried the [h]:mm format but vb does not recognise it)

Private Sub Command1_Click()
Text2.Text = Format(Text1.Text, "hh:mm")
End Sub

Thinker
09-11-2003, 09:12 AM
Time is already a double. But time in a textbox is just a string. Try...
Text2.Text = CDbl(CDate(Text1.text)) 'This assumes Text1.Text contains a valid time

If the Time in Text1.Text > "23:59:59" you will have to parse it out and
convert yourself. ((Hours * 3600) + (minutes * 60) + seconds) / 86400

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum