-
Hi
I have a ListBox with possible new filenames, say 10 items
and if I at the same time have a FileList with 10 files,
can I rename all the 10 files with the names I have in the List box in one single action.
The filenames has to be called 01-10.filename, so the app knows what it is looking for.
I have tried with For loops but I havent gotten any near it.
Hope you can help
Thanks
Best regrads,
Chris Davidsen
-
Yes. it is possible.
you can use always use For loops when dealing with collections.
For example :
For i = 0 To ListBox.ListCount
rename FileList.list(i).FileName ListBox.List(i)
Next i
I hope that solve your problem.
-
wrong number or argument
Hi rbnwares
I tried your code
amd my code looks like this
--------------------------------------
Dim Oldname
Dim Newname
For i = 0 To List1.ListCount
Label1 = i
Oldname = Dir1.Path & "\" & File1.List(i).filename
Newname = Dir1.Path & "\" & List1.List(i)
Name Oldname As Newname
Next i
---------------------------------------
but it does not like File1.List(i), wrong argument
do you have any other clues
Thanks
Chris Davidsen
-
Listindex
try list1.listindex=i instead of list1.index(i)
WP
-
i think your error might be in the fact that i becomes too big. use the list count but subtract one as in below.
For i = 0 To ListBox.ListCount - 1
rename FileList.list(i).FileName ListBox.List(i)
Next i