File2.ListIndex = File1.ListIndex
this gives an error when I check File2.ListIndex = 0 and File1.ListIndex = 1
my assumption was that FileListBox2 was not indexed so I used this code to
index the list
Copied from Sample Code @
http://vbnet.mvps.org/index.html
Dim Num as Long ' = Num of Items in List
Dim i as Long ' = i Index Number
Dim xName() as String ' = Var
fPath = Dir.Path
For Num = 0 To File2.ListCount - 1
If File1.ListCount > 0 Then
i = i + 1
ReDim Preserve xName(1 to i)
xName(i) = fPath &"\" & File2.List(Num)
End If
Next
has this indexed the File2 it seems not
This has not solved the problem can you help please?
Go back to using the above command in the Click event and find
out why it gives you an error. What is the error? Is there any other
code in the click event (of either control)?
LFS
"Larry Serflaten" wrote:
> .
>
Before the failing statement add a debug statement:
Debug.Print File1.ListCount, File2.ListCount
Check to see if the list sizes match....
LFS
"Larry Serflaten" wrote:
> .
>
Start a new project and add two file list boxes to act as you want.
See if it happens there, and if not, find the difference in your original
program. If that also errors, post the code so we can try it on our own
system...
LFS
"Larry Serflaten" wrote:
> .
>
You can share some of it without needing the author's permission, even if
the author require permission:
http://en.wikipedia.org/wiki/Fair_use
"LondonLad" <Lond...@discussions.microsoft.com> wrote
> The code I am using was not written by me so I cannot post it here, and I do
> not know how to load a FileListBox.
As you might guess, its nearly impossible to tell you what is wrong
with your code, if you never show the code you are using....
LFS
"Larry Serflaten" wrote:
> .
>
Take a moment to consider that when programing was invented, people had
no one to tell them what to do! They had to look at the tools they had
(statements, commands) and figure a way to get the job done. That is still
the essence of programming; completing the task using the tools you have.
If you wait for someone to show you all the simple tasks, you'll be old
and gray before you get 3 projects done. What did you try?
If you put a file list box on a form it fills up with files, does it not???
Had you tried to test it yourself, you would have seen that.
None the less, here is a simple example. Add 2 FileList boxes to a new
form and paste in the code below....
LFS
Private Sub Form_Load()
File1.Pattern = "*.exe"
File2.Pattern = "*.dll"
'File1.Path = "C:\Temp"
'File2.Path = "C:\Temp"
File1.Enabled = False
End Sub
Private Sub File2_Click()
If File1.ListCount > File2.ListIndex Then
File1.ListIndex = File2.ListIndex
Else
File1.ListIndex = -1
End If
End Sub
"Larry Serflaten" wrote:
> .
>
Check the Enabled property of both file lists. I think that some operations
that you can't do when it's disabled. Enable them all and see if the problem
disappears.
"Nobody" wrote:
> .
>