"Jody Gelowitz" <jo**@mail.visualstatement.com> wrote in news:

Once you have the Hours (whole number part of the value), Minutes, and

Seconds (if you are using Seconds as well), the formula is:

Value = Hours +( (Minutes + Seconds/60)/60)

If you are not using Seconds, then you would use:

Value = Hours + (Minutes/60)

Thank you Jody.

I am trying this formula, but have trouble with it.

my numbers come from a text file like: 1:15, 1:45, 10:37, 123:14. They

are always minutes, then seconds.

My code looks much more complicated than your formula, but I can't seem

to make your formula work?

Here is my code. I think I got it working, but it runs quite slow - I do

this to millions of numbers.

Public Function Time2Decimal(ByVal s As String)

Dim i As Integer

Dim dbl As Double

Dim str() As String = s.Split(":")

If str(1) = "00" Then

dbl = CType(str(0), Double)

Else

Dim dbl2 As Double = CType(str(1), Double)

dbl2 = dbl2 / 60

str(1) = dbl2.ToString

Dim split() As String = str(1).Split(".")

If split(1).Length > 2 Then

split(1) = split(1).Remove(2, split(1).Length - 2)

End If

Dim sFin As String = str(0) & "." & split(1)

dbl = CType(sFin, Double)

End If

Return dbl

End Function

Masa