Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 4012

Time format is not as expected

$
0
0

The code:

' ---- Variable Defined ----
Var dtRunStart As New date
Var dtRunStop As New date
Var curRunTime As Currency // 4 decimal precision...

' ---- Code In Action ----
Me.Text = modSystem.mthTime( )

// Start time for generator
dtRunStart.Hour = txtStartTime.Text.Left( 2 ).ToInteger
dtRunStart.Minute = txtStartTime.Text.Middle( 3, 2 ).ToInteger
dtRunStart.Second = txtStartTime.Text.Right( 2 ).ToInteger

// Stop time for generator
dtRunStop.Hour = txtStopTime.Text.Left( 2 ).ToInteger
dtRunStop.Minute = txtStopTime.Text.Middle( 3, 2 ).ToInteger
dtRunStop.Second = txtStopTime.Text.Right( 2 ).ToInteger

// Run time for generator...
curRunTime = dtRunStop.TotalSeconds - dtRunStart.TotalSeconds
curRunTime = (curRunTime / 60) / 60

// Display run time and make ready to be saved into the database...
txtRunTime.Text = curRunTime.ToString

The problem: While this works it displays the result in an format I do not want, and I have been perusing my old code and forums to try and find the solution.

The example of the problem:
In my program I enter the two times like so:
Start Generator Run: 08:32:28
Stop Generator Run: 10:19:42
And the run time is calculated then displayed like this → 1.787
But when I use LibreOffice Calc with the same times I get this → 1:47 ← THIS is what I want my program to display. So what am I doing incorrect or missing to get this format?

4 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 4012

Trending Articles