Computer Science Canada

Well...

Author:  krikor0322 [ Tue May 04, 2004 1:23 pm ]
Post subject:  Well...

Hey Im just having a little trouble with my code... i put it in the form load and when it loads its freezing... i tried putting it in a button and when i clicked the button it froze again... can someone tell me whats wrong ... or show me a more reliable and easy way to do what i was trying to do...


code:
Private Sub Form_Load()
    Dim View As Variant
    Dim counter As Integer

    View = Split(ReadFile("HighScore1.txt"), vbCrLf)

    For counter = LBound(View) To UBound(View)
        lstBox.AddItem View(counter)
    Next counter

End Sub

Public Function ReadFile(FullFilePath As String) As String
   
    Dim ReadBuffer As String * 1024
    Dim FFSlot As Integer
   
    FFSlot = FreeFile
   
    Open FullFilePath For Binary As FFSlot
        While EOF(1) = False
            Get FFSlot, , ReadBuffer
            ReadFile = ReadFile & ReadBuffer
        Wend
    Close #1

End Function

Author:  Brightguy [ Thu May 06, 2004 11:22 pm ]
Post subject:  Re: Well...

Works fine over here. Although instead of assuming the file number is 1, you should use the integer returned from FreeFile. So use EOF(FFSlot) and Close #FFSlot. If you opened another file before this with file number 1 then EOF(1) would never be False and you would be stuck in an infinite loop.

Author:  krikor0322 [ Sun May 09, 2004 8:59 am ]
Post subject:  Great

Works man thanks alot.. 8)


: