473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Pass all files listed in a FileListBox to a collection?

All,

This is a simple problem that I, for some reason, am having a hard time with. Basically I am trying to rename all the files listed in a FileListBox based on a search and replace string. I am able to accomplish this task by referencing all files in a folder using the filesystemobject but, as you can see in the code below, this attempts to rename all files in the referenced folder. I would rather reference all of the files listed in the FileListBox which is populated based on a pattern. Can someone please review the code below and point out where I am going wrong? Thanks.

P.S. I would be fine with continuing with the solution as seen below (I.e. I don't necessarily have to reference the files being displayed in the FileListBox) but I do get an error syaing "File Already Exists" after the for each statement is finished.

[code]
Private Sub Command1_Click(Index As Integer)
Dim fso As New FileSystemObject
Dim rfldr As Scripting.Folder
Set rfldr = fso.GetFolder(Form1.Dir1.Path)

'send it to a sub routine
Call GetFiles(rfldr)
End Sub



Public Sub GetFiles(rfldr As Scripting.Folder)
Dim fso As New Scripting.FileSystemObject
Dim f2 As Scripting.File

'Dim i As Integer
'Dim FileCol As New Collection
'Set FileCol = File1.List

For Each f2 In rfldr
'Do Until rfldr.Files Is Nothing
f2.Name = Replace(f2.Name, Form1.Text2.Text, Form1.Text3.Text)
Set rfldr = Nothing
Next
File1.Pattern = "*" & Text3.Text & "*"
End Sub
[code]
Sep 13 '07 #1
0 1287

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ADE | last post by:
Hi I have a Tkinter GUI with a listbox that displays a list of files I would like to be able to open those files when I double click on them in there default program that opens the files usually ...
44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
1
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into...
4
by: deko | last post by:
This is a basic program flow question. I'm trying to refractor an AC2000 app and split sections of code into separate modules. But there are a number of collections I create in one big module -...
1
by: Vernon Gainous | last post by:
Does VB.NET have it's own set of controls for accessing the file system. VB6 had a DriveListBox, DirListBox, and FileListBox controls. Where are these controls for VB.NET?
15
by: Jack | last post by:
Hi, I have a asp form where one element is a list box which lists four years starting from 2004. This list is drawn from a database table which has YearID and Year as two fields as shown below:...
0
by: akoymakoy | last post by:
how do i link my dirlistbox to the filelistbox viceversa... I would like to use the path of the file selected in the filelistbox as a variable that i would use as a location for the DB that i will...
2
by: Asprisa | last post by:
Hi There, This is probably an easy one! i am having trouble opening the files listed in a filelistbox, they are all .url files, all i want them to do is open up in the default browser, i looked...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.