Re: List1.listcount problem
I think the problem is elsewhere. A For / Next loop will execute whilst the loop control variable is less than or equal to the end value. Your Counter6 loop will execute once when i = 0. I suspect that eTitle(0) does not contain what you expect. ( I wonder if you've started at element 1 (rather than 0) when you populate eTitle)
Re: List1.listcount problem
Instead of that looping and other stuff in this portion:
vb Code:
'.....
For j = Len(strTitle) To 0 Step -1
If Mid(strTitle, j, 1) = "/" Then 'looking for leading "/" to indicate beginning of filename
strTitle = Right(strTitle, Len(strTitle) - j)
'....
Exit For
End If
Next
'....
you could extract the filename using a single line of code.
This is the code:
Code:
strTitle = Mid$(strTitle, InStrRev(strTitle, "/") + 1)
Example:
vb Code:
Option Explicit
Private Sub Command1_Click()
Dim strTitle As String
strTitle = "http://www.vbforums.com/images/logo.gif"
strTitle = Mid$(strTitle, InStrRev(strTitle, "/") + 1)
MsgBox strTitle
End Sub
...:wave:
Re: List1.listcount problem
The only 'problem' with using InStrRev like that, is if the "/" is not in the string. The code will return the complete string, since InStrRev(strTitle, "/") will return 0. I know it's not very likely to happen in this application, but ....
I'd modify the example slightly
Code:
Option Explicit
Private Sub Command1_Click()
Dim strTitle As String
Dim intI As Integer
strTitle = "http://www.vbforums.com/images/logo.gif"
intI = InStrRev(strTitle, "/")
If intI > 0 Then
strTitle = Mid$(strTitle, intI + 1)
MsgBox strTitle
Else
MsgBox "/ Not Found in Title (" & strTitle & ")"
End If
End Sub
Re: List1.listcount problem
Okay, this may have taken care of a couple of things, one related and another totally unrelated. I'm going to have to play around with the code a little to see if I can shorten the code up using the InStr concept. I'm using InStr, just not this way. I'm going to have to try the idea out all the way and see what I can come up with.
Back on the subject of List1.Listcount. I have noticed another problem now, for sure.
Code:
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
strTemp = List1.List(i)
strTemp = Mid$(strTemp, InStr(strTemp, ".") + 6)
List2.AddItem strTemp
List1.RemoveItem i
For Counter6 = 0 To Counter5
If eTitle(Counter6) = strTemp Then
eId(Counter6) = "1"
Exit For
End If
Next Counter6
End If
Next i
Call SaveList
Up where I have it in List1 where they click on the name and move it over to list two. When ever they hit enter and it runs through this list it appears that it has did everything correctly...until. Until you go take a look at the txt file. Now the top entry is missing. For example you list from before the move was:
1
2
3
4
5
After the move the the txt file on the hard drive will only show:
2
3
4
5
It has totally removed the first entry altogether.
From what I've heard to be able to remove anything from one listbox I have to use List1.Listcount -1 which is where I'm thinking the problem lies. If I remove the -1 it always comes up with Invalid Array Property Index error, #381. How do I keep from losing the first entry?