Birth
Feb 26th, 2004, 12:53 AM
This is a file that I compressed with my own algorithm (omacmodi.cpr) and need to read back (like a zip or something). Every line have a different lengh and I need to know how many entries are in there so I can display the pourcentage on a progress bar.
Not only I can't find a better way to do this but I find that the calculation for "FloodPercent" is a little bit suspicious...
It works, but is there a better way?
Open App.Path & "\omacmodi.cpr" For Input As #1
' Count the number of records (or entries).
While Not EOF(1)
Input #1, A$: NB = NB + 1
Wend
Seek #1, 1 ' Back to beginning of file
While Not EOF(1)
Input #1, A$: Rec = Rec + 1
If 100 - Int(((100 / NB * (NB - Rec)))) <> LastRec Then
Frm_Modi.Pnl_Status.FloodPercent = 100 - Int(((100 / NB * (NB - Rec))))
End If
LastRec = 100 - Int(((100 / NB * (NB - Rec))))
' If I don't do this, the form is not refreshed. That's another thing!
openforms = DoEvents
If Len(A$) <> 3 Then
MODE$ = Left$(A$, 3)
For I = 4 To Len(A$) - 5 Step 5
code$ = Mid$(A$, I + 1, 5)
TB_OM.AddNew
TB_OM("Code") = code$
TB_OM("Mode") = MODE$
TB_OM.Update
Next
End If
Wend
It took me about a day to build this like 5 years ago. It's the pourcentage that was a *****!
Can anyone make this better or is it just a piece of art like it is? (ya)
Thank you.
PS: There's only 5 hits for "Some wild calculations" on Google
Not only I can't find a better way to do this but I find that the calculation for "FloodPercent" is a little bit suspicious...
It works, but is there a better way?
Open App.Path & "\omacmodi.cpr" For Input As #1
' Count the number of records (or entries).
While Not EOF(1)
Input #1, A$: NB = NB + 1
Wend
Seek #1, 1 ' Back to beginning of file
While Not EOF(1)
Input #1, A$: Rec = Rec + 1
If 100 - Int(((100 / NB * (NB - Rec)))) <> LastRec Then
Frm_Modi.Pnl_Status.FloodPercent = 100 - Int(((100 / NB * (NB - Rec))))
End If
LastRec = 100 - Int(((100 / NB * (NB - Rec))))
' If I don't do this, the form is not refreshed. That's another thing!
openforms = DoEvents
If Len(A$) <> 3 Then
MODE$ = Left$(A$, 3)
For I = 4 To Len(A$) - 5 Step 5
code$ = Mid$(A$, I + 1, 5)
TB_OM.AddNew
TB_OM("Code") = code$
TB_OM("Mode") = MODE$
TB_OM.Update
Next
End If
Wend
It took me about a day to build this like 5 years ago. It's the pourcentage that was a *****!
Can anyone make this better or is it just a piece of art like it is? (ya)
Thank you.
PS: There's only 5 hits for "Some wild calculations" on Google