Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Integer to Time format 1

Status
Not open for further replies.

Anesthaesia

Technical User
Aug 30, 2001
126
GB
I need to convert an integer to time format ie. 127.8347 would be 2:07.8347

I have found examples that convert to hh:mm:ss but do not allow for milliseconds.

Any help would be great.
 
This seems to do it
Code:
x = 127.8347
? Format(x \ 60,"00") & ":" 
  Format(Int(x) Mod 60,"00") & "." & 
  Format(10000 * (x - int(x)),"0000")
02:07.8347

VB.Net has a Format character "f" as in
Code:
Format ( SomeTime, "hh:nn:ss.ffff" )
That will do that but it doesn't seem to be supported in VB6.
 
What type of Integer is 127.8347?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Let's see. I think it's a "fixed point integer" variable. yeah, that's it.....
 
BobRodes,
please elaborate. Now you just puzzled me beyond words...
 
Maybe Bob and I should have used the [lol] symbol to make it clear that it was a joke. An integer is by definition a whole number, so can't have a decimal point

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
I wanted to use that, but couldn't find it. :) But really, I was half serious.

The Currency type is actually stored internally as a 64 bit "scaled" integer. Scaling simply means that a correction factor (in the case of the Currency type, the factor is .0001) is applied to the integer at point of access.

For more info:
Bob
 
An integer is by definition a whole number,...
To put a fine point on it, no, it isn't. Negative numbers are not, by definition, whole numbers. Whole numbers are defined as the non-negative subset of integers. Integers are the counting numbers, their negatives, and zero. Except for the size restriction, the integer datatype in VB corresponds to the mathematical definition.

Some languages, such as Pascal, draw the distinction with integer datatypes and cardinal (whole number) datatypes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top