Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Well...
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
krikor0322




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Brightguy




PostPosted: 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.
krikor0322




PostPosted: Sun May 09, 2004 8:59 am   Post subject: Great

Works man thanks alot.. 8)
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: