Error While Reading A Text File

jothis

Active Member
Licensed User
Hi
I Created A Program For Read A Text File And List Items To A listbox.
But When I Try To List I Got A Error.

I Attached My Code Here.
Please Help Me?
jothis
:sign0085:
 

Attachments

  • Error.zip
    805 bytes · Views: 164

klaus

Expert
Licensed User
Longtime User
It's normal that you get an error.
In your code you try to read the variable 'count', which is supposed to be the number of entries, but this one doesn't exist in your file !
Try the attached code.

Best regards.
 

Attachments

  • 01.sbp
    871 bytes · Views: 179

jothis

Active Member
Licensed User
Thankyou for helping me klaus

but it read only the last row of the document

FileOpen(c1,path,cRead)
a = FileRead(c1)
Do While a<>EOF
s = FileRead(c1)
If s=EOF Then Exit
ListBox1.Add(s)
Loop

What Should i do For Listing full Row Of The Document?
Please Help me
jothis
 

klaus

Expert
Licensed User
Longtime User
The code I posted
DoWhile s<>EOF
s = FileRead(c1)
If s=EOF Then Exit
ListBox1.Add(s)
Loop
works fine for me.

In your code you read the first line with
a = FileRead(c1) but you don't add it to the ListBox !

This code works also, but the first two lines are not necessary.
s = FileRead(c1)
ListBox1.Add(s)
DoWhile s<>EOF
s = FileRead(c1)
If s=EOF Then Exit
ListBox1.Add(s)
Loop

Best regards.
 
Top