I need a function to get final value in min.sec.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Astrotech
    New Member
    • May 2019
    • 1

    #1

    I need a function to get final value in min.sec.

    Substract 82.30 - 72.50 (Type Degree)
    Answer require : 09.40 (Type Degree)
    Multiply : 09 x 4 Second
    Ans : 36 Min
    Multiply : 40 x 4 Second
    Ans : 160 Second
    convert : 36 Min.160 Sec
    as 36 Min. + 2 Min 40 Second
    Final Ans require : 38 Min. 40 Sec
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Can you explain in words what you are trying to do?
    I am alrady loast at your second sentence:
    "Answer require : 09.40 (Type Degree)"

    You need a 'final value in min.sec', but do not specify what 82.30 and 72.50 is.

    What correlation has 'Degree' with min.sec. ?

    Comment

    • SioSio
      Contributor
      • Dec 2019
      • 272

      #3
      Conversion from Integer type to TimeSpan Type
      Code:
      Dim imin As Integer = 82
      Dim isec As Integer = 30
      Dim ts1 As New TimeSpan(0, imin, isec)
      Time calculation (adjustment)
      Code:
      Dim ts1 As New TimeSpan(0, 82, 30)
      Dim ts2 As New TimeSpan(0, 72, 50)
      Dim ts3 As TimeSpan = ts1 - ts2
      Convert
      Code:
      Dim ts3 As New TimeSpan(0, 36, 160)
      Time calculation(mul tiplication)
      Code:
      Dim L As Long  = ts1.Ticks * 7
      To Striing
      Code:
      Dim min As String = Mid(ts3.ToString,4,2)
      Dim sec As String = Mid(ts3.ToString,7,2)
      Last edited by gits; Dec 16 '19, 07:00 AM. Reason: added code tags

      Comment

      • cactusdata
        Recognized Expert New Member
        • Aug 2007
        • 224

        #4
        You can handle your degrees as timespans:

        Code:
        Dim StartValue As TimeSpan = New TimeSpan(0, 72, 50)
        Dim StopValue As TimeSpan = New TimeSpan(0, 82, 30)
        
        Dim Factor As Double = 4
        Dim Final As TimeSpan = TimeSpan.FromSeconds(StopValue.Subtract(StartValue).TotalSeconds * Factor)
        
        Console.WriteLine(Final.ToString("mm':'ss"))
        
        ' -> 38:40

        Comment

        Working...