|
-
Aug 8th, 2002, 09:32 AM
#1
Thread Starter
Hyperactive Member
Annoying loop is stuck!
VB Code:
Private Sub LstSites_Click()
If checkfile("links.txt") = True Then
Open "links.txt" For Input As #1
While Not EOF(1)
Line Input #1, strleesin
If Not strleesin = "" Then
If InStr(1, strleesin, ",") = True Then 'Categorie gevonden
strtemp1 = Split(strleesin, " , ")(0)
strtemp2 = Split(strleesin, " , ")(1)
If strtemp1 = LstSites.Text Then
LstSites.Text = strtemp1
LstCat.Text = strtemp2
End If
Else 'Geen categorie gevonden
strtemp1 = strleesin
strtemp2 = ""
If strtemp1 = LstSites.Text Then
LstSites.Text = strtemp1
LstCat.Refresh
End If
End If
End If
Wend
Close #1
End If
End Sub
Can somebody explain why he also loops the opening of the file en the filecheck procedure? It crashes and says: File already open. That's because something loops my whole sub again! I don't know how!
Kind Regards,
Pieter
PS: If you found someone's answer helpful, please be so kind to rate that person.
Thanks.
-
Aug 8th, 2002, 09:37 AM
#2
I wonder how many charact
what line is the program stoppin at?
-
Aug 8th, 2002, 09:39 AM
#3
Thread Starter
Hyperactive Member
The open file as #1 line
Kind Regards,
Pieter
PS: If you found someone's answer helpful, please be so kind to rate that person.
Thanks.
-
Aug 8th, 2002, 09:40 AM
#4
Fanatic Member
Changing the value probably fires the Click event.
Put something like this around all the code in your procedure:
VB Code:
If Not m_blnClick Then
m_blnClick = True
...
m_blnClick = False
End If
m_blnClick is a module level variable.
-
Aug 8th, 2002, 09:59 AM
#5
Hyperactive Member
Try this...
VB Code:
Private Sub LstSites_Click()
Dim MyFileNumber as Integer
If checkfile("links.txt") = True Then
MyFileNumber = FreeFile
Open "links.txt" For Input As #MyFileNumber
While Not EOF(MyFileNumber)
Line Input #MyFileNumber, strleesin
If Not strleesin = "" Then
If InStr(1, strleesin, ",") = True Then 'Categorie gevonden
strtemp1 = Split(strleesin, " , ")(0)
strtemp2 = Split(strleesin, " , ")(1)
If strtemp1 = LstSites.Text Then
LstSites.Text = strtemp1
LstCat.Text = strtemp2
End If
Else 'Geen categorie gevonden
strtemp1 = strleesin
strtemp2 = ""
If strtemp1 = LstSites.Text Then
LstSites.Text = strtemp1
LstCat.Refresh
End If
End If
End If
Wend
Close #MyFileNumber
End If
End Sub
I put there the FreeFile instruction so you'll get the next file handle available...Good luck!
"Who Dares Wins" - "Quien se Arriesga Gana"
Mail me at: 
-
Aug 8th, 2002, 10:01 AM
#6
Thread Starter
Hyperactive Member
By changing the list text it indeed triggered the click event! Thx for all the help!
Greetz Pierre
Kind Regards,
Pieter
PS: If you found someone's answer helpful, please be so kind to rate that person.
Thanks.
-
Aug 8th, 2002, 10:17 AM
#7
Hyperactive Member
Did you try to debug your application stepping one line at a time? If you did you would have seen that when it changed the text that it did not finish the routine and started the click routine over again. Stepping one line at a time can be very helpful in debugging your application. Hope that'll help you in the future.
Joe
-
Aug 8th, 2002, 10:19 AM
#8
Frenzied Member
i think the bug is just in Open "links.txt" For Input As #1
doesnt it always need a full path and drivename etc etc?
try this:
Filename = app.path &"\links.txt"
Open filename For Input As #1
-
Aug 8th, 2002, 11:03 AM
#9
Hyperactive Member
No snake, the loop is the result of changing the text. The textfile automatically opens the file in the current directory if none is specified.
Joe
P.S. I hate using App.Path. There is one major problem with it; if your application is not run from the root of a drive then the App.Path has no '\', but if it is run from the root it contains the '\' which means any code written App.Path + "\myfile" fails when run from the root. I always declare a public variable called AppPath that always contains the '\' at the end.
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
|