Results 1 to 6 of 6

Thread: Working with Time [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Working with Time [RESOLVED]

    In a program I'm working on I'm trying to read text log files import them into a DB and sum the CPU time certain processes are using. The only problem is I'm not sure you can add something like 40:30 + 113:47 to get 154:17 in an HHH:MM format (or anything similar). Any suggestions?
    Last edited by bat711; Apr 12th, 2005 at 05:25 PM.

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Working with Time

    There may well be a simpler way but this works

    VB Code:
    1. Const TIME1 = "40:30"
    2.     Const TIME2 = "113:47"
    3.     Dim strParts1() As String
    4.     Dim strParts2() As String
    5.     Dim intMinutes As Integer
    6.    
    7.     strParts1 = Split(TIME1, ":")
    8.     strParts2 = Split(TIME2, ":")
    9.    
    10.     intMinutes = CInt(strParts1(1)) + CInt(strParts2(1))
    11.     If intMinutes > 59 Then
    12.         MsgBox CInt(strParts1(0)) + CInt(strParts2(0)) _
    13.             + (CInt(strParts1(1)) + CInt(strParts2(1))) \ 60 _
    14.             & ":" & Format((CInt(strParts1(1)) + CInt(strParts2(1))) Mod 60, "00")
    15.     Else
    16.         MsgBox CInt(strParts1(0)) + CInt(strParts2(0)) _
    17.             & ":" & Format((CInt(strParts1(1)) + CInt(strParts2(1))), "00")
    18.     End If

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Working with Time

    That's about what I figured, and was afraid of. Now I just need to figure out a way to read in the log file...

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Working with Time

    Thanks I was able to use this general idea in the program and it works nicely. Unfortunately the log files I'm working with don't have a good format to work with so it looks like the project will die. Thanks for your help again.

  5. #5

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Working with Time [RESOLVED]

    http://www.vbforums.com/showthread.php?t=333701

    I think this is the log file he's referring to. I wrote a function which extracts the time and returns it in string format.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width