Results 1 to 14 of 14

Thread: [RESOLVED] Time unit?

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Resolved [RESOLVED] Time unit?

    Hey all,
    I'm converting an old project from vb6 to .net and have this line....

    Code:
    Z = Time + 0.0001
    Z is a variant and I know Time return the system time, but what would be the time unit of what is added ? Minutes, Hours Seconds?
    Thanks
    Kevin
    Last edited by kebo; Nov 7th, 2017 at 12:16 PM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Time unit?

    Looks like minutes to me just doing a display.
    Please remember next time...elections matter!

  3. #3

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Time unit?

    Sound reasonable.
    Thanks
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: [RESOLVED] Time unit?

    Looks like almost 9 minutes.

    1 min is 0.0000115740741
    9 min is 0.0001041666667

    Just use the DateAdd() function instead to add intervals.

  5. #5

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: [RESOLVED] Time unit?

    hmmmm.... Based on how the program currently runs, I don't think it's on the order of minutes (maybe though).

    Essentially the time is a wait between database writes. If the write fails, the code stops for a little bit then tries again.

    Here is the exact VB6 code (this is not my code, it's what I need to convert)
    VB6 Code:
    1. ILoop = 1
    2. Do While ILoop <= 3
    3.   Err = 0
    4.     On Error Resume Next
    5.   WConn.Execute (sSql)
    6.  
    7.   If Err = 0 Then Exit Do
    8.   ILoop = ILoop + 1
    9.   Z = Time + 0.0001
    10.   Do While Time < Z
    11.     DoEvents
    12.   Loop
    13. Loop
    WConn is an ADODB.Connection that is connected to a Progress DB which I have very little experience with so I'm trying to duplicate the timing of the code (not the structure).
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Time unit?

    Looks like garbage code to me. Looping and DoEvents? Crazy.

    Why not just let the Provider manage retries?

    Code:
        Const JET_TCM_SYNCFLUSH = 1
        Const MAX_LOCK_RETRIES = 5
    
        With Connection.Properties
            .Item("Jet OLEDB:Transaction Commit Mode").Value = JET_TCM_SYNCFLUSH
            .Item("Jet OLEDB:Lock Delay").Value = 90 + Int(Rnd() * 60)
            .Item("Jet OLEDB:Lock Retry").Value = MAX_LOCK_RETRIES
        End With
    Change the properties to match your RDBMS Provider's properties.

  7. #7
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: [RESOLVED] Time unit?

    Quote Originally Posted by dilettante View Post
    Looks like almost 9 minutes.

    1 min is 0.0000115740741
    9 min is 0.0001041666667

    Just use the DateAdd() function instead to add intervals.
    I was definitely off. Here is a quick set of displays and odd results:


    Private Sub Command_Click()

    Dim Z As Variant
    Z = Time + 0.0001
    Debug.Print Z

    Z = Time + 0.0002
    Debug.Print Z

    Z = Time + 0.0003
    Debug.Print Z

    Z = Time + 0.0004
    Debug.Print Z

    Z = Time + 0.0005
    Debug.Print Z

    End Sub

    12:33:50 PM
    12:33:58 PM
    12:34:07 PM
    12:34:16 PM
    12:34:24 PM
    Please remember next time...elections matter!

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Time unit?

    Ugh!

    It looks like "Progress" (has a new name now, "Open"-something-or-other, gag) relies on the thunk through MSDASQL, the ODBC adapter Provider. That only offers limited capabilities and a limited set of Provider properties

  9. #9
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Time unit?

    It sounds like "Time" is something defined local to the procedure or module, overloading VBA.Time in the current symbol namespace.

  10. #10

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Time unit?

    Quote Originally Posted by TysonLPrice
    I was definitely off. Here is a quick set of displays and odd results:
    Thanks for that. It looks like 0.0001 equates to about 8-9 seconds then, unless my math is off which may very well be the case. This code base has me very far off my game.

    Quote Originally Posted by dilettante
    Ugh!
    This is where I confess my ignorance. This is the first Progress DB I've dealt with.

    Quote Originally Posted by dilettante
    It sounds like "Time" is something defined local to the procedure or module, overloading VBA.Time in the current symbol namespace.
    I don't think so. When I right click and view the definition of Time the object browser is telling me it's a member of the DateTime Class.Name:  Capture.jpg
Views: 293
Size:  23.6 KB
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  11. #11
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Time unit?

    Try this:

    Code:
    Debug.Print Time, Time + 0.0001

  12. #12

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Time unit?

    Quote Originally Posted by dilettante View Post
    Try this:

    Code:
    Debug.Print Time, Time + 0.0001
    Yea, I should have done that to start. I don't like this code base much at all. It's got me pulling my hair out. Thousands of line of code and all the variables used are in a public module. sigh
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  13. #13
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,914

    Re: [RESOLVED] Time unit?

    Since it hasn't previously been said, I'll say it. In VB6, Time returns a Date type variable. These Date types are just a special case of Double types (IEEE double). Therefore, we see that they're just floating-point data.

    For the Date type, the integer portion is a count of days that has elapsed since 12/30/1899. The fractional portion is simply the portion of a day that has elapsed since midnight.

    With that information, you can do regular math with these Date type variables, and you can figure out what any fraction means, like 0.0001 (which is approximately 8.64 seconds, which I figured out by 24 hours * 60 minutes * 60 seconds * 0.0001).

    Good Luck,
    Elroy

    EDIT1: Correction: It's not approximately 8.64 seconds, it's exactly 8.64 seconds.
    EDIT2: However, to be totally precise, your 0.0001 can't be perfectly represented in an IEEE double, with the closest approximation being 0.000100000000000000004792173602386. That's very close, but not exactly the same number. Therefore, I'll go back and say that 24 * 60 * 60 * 0.0001# is approximately 8.64 seconds.
    Last edited by Elroy; Nov 7th, 2017 at 02:22 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  14. #14

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: [RESOLVED] Time unit?

    Good stuff. Thanks for that.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

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