|
-
Jun 5th, 2004, 12:47 PM
#1
Thread Starter
New Member
VB 6.0 do loop error (resolved)
Hi, i've got a DO - LOOP, but after running it once, it stops, and exits the sub (I think, 'cause he doesnt do the actions after the loop)
(the file he opens has more than 1 line, so he must run the loop more than 1 time)
here is the code:
fnum = FreeFile
Open file_name For Input As fnum
TreeView1.Nodes.Clear
Do While Not EOF(fnum)
' Get a line.
Line Input #fnum, text_line
getip = Left(text_line, 15)
getnick = Mid(text_line, 16, Len(text_line))
TreeView1.Nodes.Add , , "ip" & getip, getnick, 1
Loop
Close fnum
does anyone know why he does this?
tnx
Last edited by Deefeketje; Jun 7th, 2004 at 05:23 AM.
-
Jun 5th, 2004, 01:42 PM
#2
Because he's not a good guy? 
Does the text file have just one line in it by any chance?
-
Jun 5th, 2004, 01:50 PM
#3
Re: VB 6.0 do loop error
Originally posted by Deefeketje
Hi, i've got a DO - LOOP, but after running it once, it stops, and exits the sub (I think, 'cause he doesnt do the actions after the loop)
(the file he opens has more than 1 line, so he must run the loop more than 1 time)
here is the code:
fnum = FreeFile
Open file_name For Input As fnum
TreeView1.Nodes.Clear
Do While Not EOF(fnum)
' Get a line.
Line Input #fnum, text_line
getip = Left(text_line, 15)
getnick = Mid(text_line, 16, Len(text_line))
TreeView1.Nodes.Add , , "ip" & getip, getnick, 1
Loop
Close fnum
does anyone know why he does this?
tnx
What is the value of file_name? Does it containd the path as well as the file name?
-
Jun 5th, 2004, 02:23 PM
#4
Thread Starter
New Member
yes, file_name is the path and filename
this is the code for filr_name
file_name = App.Path
If Right$(file_name, 1) <> "\" Then file_name = file_name & "\"
file_name = file_name & "contacts.txt"
the strange thing is..
the first time he does this loop..everything goes perfect..
but the second time..nothing is done of the actions..
-
Jun 5th, 2004, 02:27 PM
#5
Thread Starter
New Member
the txtfile has more lines
it is like this:
#1 ipadress, nickname
#2 ipadress, nickname
#3 ipadress, nickname
#4 ipadress, nickname
#5 ipadress, nickname
...
every line is a different user
-
Jun 5th, 2004, 02:57 PM
#6
The picture isn't missing
try this
fnum = FreeFile
Open file_name For Input As #fnum
Close #fnum
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jun 5th, 2004, 03:04 PM
#7
Thread Starter
New Member
it's the same..
I add 1 person..everything is perfect..
1 restart..add another one.. still going good..
but after the next restart he does the same as before..
(with the restart of the program, it saves the treeview in the txt file, and if the program starts again, it opends the txtfile in the treeview)
so I only get the first contact..and if I shut down the program..I get an error that it cant save the treeview 'cause the txt file is still open..so you see that he doesnt finishes the loop
-
Jun 6th, 2004, 02:39 AM
#8
Thread Starter
New Member
ok, thank you guys, but I've found the problem myselve 
he stopped the loop because he wanted to add a new contact with the same treeviewkey, so I changed the save procedure..and now everything is perfect!
but thanks for helping!
-
Jun 6th, 2004, 09:08 PM
#9
OK, so now please add resolved to the Subject of the first post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|