Visual Basic 6 problem

[Dragoon]

Vortigaunt
Joined
Feb 27, 2004
Messages
840
Reaction score
6
This isn't mod related, so I'm not totally sure this is the right place to post this. Sorry if it isn't.

I'm working on a pretty simple program in Visual Basic 6, and I've run into a problem. I need it to open a file, and then put it in a textbox. I've got it to open it, but it doesn't seem to like commas. It only reads until the first one.

Any idea what the problem is, and how I could fix it?

Edit: Here's the code I'm using.

Code:
Open txt_fileLocation.Text For Input As #1
Input #1, Temp1
txt_savedVariables.Text = Temp1
Close #1
 
Im not sure (cuz it's been a while since I programmed in VB6) but maybe if you add a "while not end of file loop" it will read all the file till the end.

Code:
Dim Line As String

Open txt_fileLocation.Text For Input As #1
   While Not (EOF(1))
       Input #1, Line
       txt_savedVariables.Text = txt_savedVariables.Text & Line
   Wend
Close #1
 
You'll want the LineInput command instead of Input. That ignores commas, bringing in entire lines up to carriage returns.
 
Ti133700N said:
Im not sure (cuz it's been a while since I programmed in VB6) but maybe if you add a "while not end of file loop" it will read all the file till the end.

Code:
Dim Line As String

Open txt_fileLocation.Text For Input As #1
   While Not (EOF(1))
       Input #1, Line
       txt_savedVariables.Text = txt_savedVariables.Text & Line
   Wend
Close #1

That code seems to freeze it... The file it's reading is rather large, over 30,000 lines and just under 700 Kb, so I'm not sure it'll work at all.. I seem to remember a command that would allow other thing in the program to continue working while a command like that ran that would avoid freezing, is there one or am I mistaken?

Edit: If anyone is wondering, the file that it's parsing is the SavedVariables.lua file for World of Warcraft. Trying to get it to parse out the guild information gathered by a mod and then upload it to our guild website.
 
Well, it is working... Just incredibly slow. It'll take hours to load the file at this rate.
 
Read the text into an array of strings rather than append a textbox. Then fill the textbox with the array contents. I guarantee that will run nearly instantaneously.
 
FictiousWill said:
Read the text into an array of strings rather than append a textbox. Then fill the textbox with the array contents. I guarantee that will run nearly instantaneously.

It's been a while since I last wrote anything in VB, and I'm not very good with it anyway. How would I go about doing that?
 
I think I have vb on this comp. I haven't written anything in it for a year, but seeing as I used to be able to do shit like this, (shameless plug :D) I'll see if I can get you some working code in the next 15 mins.
 
FictiousWill said:
I think I have vb on this comp. I haven't written anything in it for a year, but seeing as I used to be able to do shit like this, (shameless plug :D) I'll see if I can get you some working code in the next 15 mins.

Thanks. I'm about to go to the store to buy some food, and then I'll be cooking for a while, so there's no rush.
 
Well I went off and wrote some crazy string array function that was sortof faster, only to find that the one that already exists is faster still. I've never really used vb to input text files before, but oh well. here's the code:

Code:
Open app.path & "thefile.txt" For Input As #1
         Text1.Text = Input(LOF(1), #1)
Close #1
'app.path lets you use relative file locations, my test app loaded
'a file in the apps' root directory, in case you were wondering.

Also I was wrong before, I said "LineInput" when the syntax is "Line Input", which is still handy for doing line-by line parsing on loads for small files. My test file was about 3000 lines and took way to long to load this way though.
 
Back
Top