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?

VB Code:
  1. Open App.Path & "\omacmodi.cpr" For Input As #1
  2.    
  3.    ' Count the number of records (or entries).
  4.    While Not EOF(1)
  5.       Input #1, A$: NB = NB + 1
  6.    Wend
  7.    
  8.    Seek #1, 1   ' Back to beginning of file
  9.    
  10.    While Not EOF(1)
  11.    
  12.       Input #1, A$: Rec = Rec + 1
  13.      
  14.       If 100 - Int(((100 / NB * (NB - Rec)))) <> LastRec Then
  15.          Frm_Modi.Pnl_Status.FloodPercent = 100 - Int(((100 / NB * (NB - Rec))))
  16.       End If
  17.  
  18.       LastRec = 100 - Int(((100 / NB * (NB - Rec))))
  19.  
  20.       ' If I don't do this, the form is not refreshed. That's another thing!
  21.       openforms = DoEvents
  22.      
  23.       If Len(A$) <> 3 Then
  24.      
  25.          MODE$ = Left$(A$, 3)
  26.      
  27.          For I = 4 To Len(A$) - 5 Step 5
  28.          
  29.             code$ = Mid$(A$, I + 1, 5)
  30.            
  31.             TB_OM.AddNew
  32.             TB_OM("Code") = code$
  33.             TB_OM("Mode") = MODE$
  34.             TB_OM.Update
  35.          
  36.          Next
  37.      
  38.       End If
  39.      
  40.    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