Hey all,
I'm converting an old project from vb6 to .net and have this line....
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?Code:Z = Time + 0.0001
Thanks
Kevin
Printable View
Hey all,
I'm converting an old project from vb6 to .net and have this line....
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?Code:Z = Time + 0.0001
Thanks
Kevin
Looks like minutes to me just doing a display.
Sound reasonable.
Thanks
Looks like almost 9 minutes.
1 min is 0.0000115740741
9 min is 0.0001041666667
Just use the DateAdd() function instead to add intervals.
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)
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).VB6 Code:
ILoop = 1 Do While ILoop <= 3 Err = 0 On Error Resume Next WConn.Execute (sSql) If Err = 0 Then Exit Do ILoop = ILoop + 1 Z = Time + 0.0001 Do While Time < Z DoEvents Loop Loop
Looks like garbage code to me. Looping and DoEvents? Crazy.
Why not just let the Provider manage retries?
Change the properties to match your RDBMS Provider's properties.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
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
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
It sounds like "Time" is something defined local to the procedure or module, overloading VBA.Time in the current symbol namespace.
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 TysonLPrice
This is where I confess my ignorance. This is the first Progress DB I've dealt with.Quote:
Originally Posted by dilettante
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.Attachment 153431Quote:
Originally Posted by dilettante
Try this:
Code:Debug.Print Time, Time + 0.0001
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.
Good stuff. Thanks for that.