473,668 Members | 2,486 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recursive File Search VBA vs VB

Hopefully a stupid question, but it doesn't appear that way. Found an
example of a recursive file search, which is exactly what I want, at
Randy Birch's site (mvps.vbnet), but VBA is just different enough not
to compile.

Has anyone successfully adapted this to VBA? Any suggestions?

(Well, short of "go back to your village!")

thanks!

Pieter

Nov 13 '05 #1
8 13709
pi********@hotm ail.com wrote:
Hopefully a stupid question, but it doesn't appear that way. Found an
example of a recursive file search, which is exactly what I want, at
Randy Birch's site (mvps.vbnet), but VBA is just different enough not
to compile.

Has anyone successfully adapted this to VBA? Any suggestions?

(Well, short of "go back to your village!")

thanks!

Pieter


There's more than 1 there, which one?

--
[OO=00=OO]
Nov 13 '05 #2
pi********@hotm ail.com wrote:
Hopefully a stupid question, but it doesn't appear that way. Found an
example of a recursive file search, which is exactly what I want, at
Randy Birch's site (mvps.vbnet), but VBA is just different enough not
to compile.

Has anyone successfully adapted this to VBA? Any suggestions?

(Well, short of "go back to your village!")

thanks!

Pieter


There's more than 1 there, which one?

--
[OO=00=OO]
Nov 13 '05 #3
You can adopt the following code that I used in ms-access.

Sub dirTest()

Dim dlist As New Collection
Dim startDir As String
Dim i As Integer

startDir = "C:\access\ "
Call FillDir(startDi r, dlist)

MsgBox "there are " & dlist.Count & " in the dir"

' lets printout the stuff into debug window for a test

For i = 1 To dlist.Count
Debug.Print dlist(i)
Next i

End Sub
Sub FillDir(startDi r As String, dlist As Collection)

' build up a list of files, and then
' add add to this list, any additinal
' folders

Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant

strTemp = Dir(startDir)

Do While strTemp <> ""
dlist.Add startDir & strTemp
strTemp = Dir
Loop

' now build a list of additional folders
strTemp = Dir(startDir & "*.", vbDirectory)

Do While strTemp <> ""
If (strTemp <> ".") And (strTemp <> "..") Then
colFolders.Add strTemp
End If
strTemp = Dir
Loop

' now process each folder (recursion)
For Each vFolderName In colFolders
Call FillDir(startDi r & vFolderName & "\", dlist)
Next vFolderName

End Sub

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #4
You can adopt the following code that I used in ms-access.

Sub dirTest()

Dim dlist As New Collection
Dim startDir As String
Dim i As Integer

startDir = "C:\access\ "
Call FillDir(startDi r, dlist)

MsgBox "there are " & dlist.Count & " in the dir"

' lets printout the stuff into debug window for a test

For i = 1 To dlist.Count
Debug.Print dlist(i)
Next i

End Sub
Sub FillDir(startDi r As String, dlist As Collection)

' build up a list of files, and then
' add add to this list, any additinal
' folders

Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant

strTemp = Dir(startDir)

Do While strTemp <> ""
dlist.Add startDir & strTemp
strTemp = Dir
Loop

' now build a list of additional folders
strTemp = Dir(startDir & "*.", vbDirectory)

Do While strTemp <> ""
If (strTemp <> ".") And (strTemp <> "..") Then
colFolders.Add strTemp
End If
strTemp = Dir
Loop

' now process each folder (recursion)
For Each vFolderName In colFolders
Call FillDir(startDi r & vFolderName & "\", dlist)
Next vFolderName

End Sub

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #5
Which one. Sorry, for some weird reason, I can't get the complete web
page address. but it's "Recursive File Search Demo - Multiple File
Types".

I got it to work. Except for the

List1.Clear

line. Apparently, VB6 and VBA are just ever so slightly different to
make porting the code really annoying. I stripped out all the
references to default properties, like .Text for textboxes and it
worked fine except for the List1.Clear. How to do that - I'm not sure
I'm that worried. Maybe set the thing's rowsource to nothing and
requery it... other than that, it seems to be working. If anyone's
interested, I'll post the code. The changes are basically minor.
Remove all references to default properties, change the rowsource type
of the listbox to Value List and away you go.

Nov 13 '05 #6
Which one. Sorry, for some weird reason, I can't get the complete web
page address. but it's "Recursive File Search Demo - Multiple File
Types".

I got it to work. Except for the

List1.Clear

line. Apparently, VB6 and VBA are just ever so slightly different to
make porting the code really annoying. I stripped out all the
references to default properties, like .Text for textboxes and it
worked fine except for the List1.Clear. How to do that - I'm not sure
I'm that worried. Maybe set the thing's rowsource to nothing and
requery it... other than that, it seems to be working. If anyone's
interested, I'll post the code. The changes are basically minor.
Remove all references to default properties, change the rowsource type
of the listbox to Value List and away you go.

Nov 13 '05 #7
pi********@hotm ail.com wrote:
Which one. Sorry, for some weird reason, I can't get the complete web
page address. but it's "Recursive File Search Demo - Multiple File
Types".

I got it to work. Except for the

List1.Clear

line. Apparently, VB6 and VBA are just ever so slightly different to
make porting the code really annoying. I stripped out all the
references to default properties, like .Text for textboxes and it
worked fine except for the List1.Clear. How to do that - I'm not sure
I'm that worried. Maybe set the thing's rowsource to nothing and
requery it... other than that, it seems to be working. If anyone's
interested, I'll post the code. The changes are basically minor.
Remove all references to default properties, change the rowsource type
of the listbox to Value List and away you go.


Yes, List1.Rowsource ="", shouldn't need to requery as changing the
rowsource automatically does that.

--
[OO=00=OO]
Nov 13 '05 #8
pi********@hotm ail.com wrote:
Which one. Sorry, for some weird reason, I can't get the complete web
page address. but it's "Recursive File Search Demo - Multiple File
Types".

I got it to work. Except for the

List1.Clear

line. Apparently, VB6 and VBA are just ever so slightly different to
make porting the code really annoying. I stripped out all the
references to default properties, like .Text for textboxes and it
worked fine except for the List1.Clear. How to do that - I'm not sure
I'm that worried. Maybe set the thing's rowsource to nothing and
requery it... other than that, it seems to be working. If anyone's
interested, I'll post the code. The changes are basically minor.
Remove all references to default properties, change the rowsource type
of the listbox to Value List and away you go.


Yes, List1.Rowsource ="", shouldn't need to requery as changing the
rowsource automatically does that.

--
[OO=00=OO]
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1585
by: alanwo | last post by:
For recursive search for files, like http://support.microsoft.com/default.aspx?scid=KB;EN-US;306666, it may lead to "out of stack" error if searching too many files, say millions of files. Do you all experts have any solution for this situation?
6
4528
by: Talin | last post by:
I've been using generators to implement backtracking search for a while now. Unfortunately, my code is large and complex enough (doing unification on math expressions) that its hard to post a simple example. So I decided to look for a simpler problem that could be used to demonstrate the technique that I am talking about. I noticed that PEP 255 (Simple Generators) refers to an implementation of the "8 Queens" problem in the lib/test...
0
401
by: pietlinden | last post by:
Hopefully a stupid question, but it doesn't appear that way. Found an example of a recursive file search, which is exactly what I want, at Randy Birch's site (mvps.vbnet), but VBA is just different enough not to compile. Has anyone successfully adapted this to VBA? Any suggestions? (Well, short of "go back to your village!") thanks!
3
2794
by: Ameen | last post by:
I am very new to programming and VB.net, and I wrote the code below, but it seem to go on an infinite loop. Please tell me what I am doing wrong. Private Sub search(ByVal indexstart) Pos1 = LineNoSpace.IndexOf("<!--", indexstart) 'checks for the begining of the comment While Pos1 = -1 And Not (line Is Nothing) ' keep checking till
3
2203
by: Robertico | last post by:
I'am new to php and have a question about a recursive file search. I'd like to do a recursive search for jpg-files and add the filenames (full path) to a mysql database. I appreciate any help ! Regards, Robertico
10
2555
by: AsheeG87 | last post by:
Hello Everyone! I have a linked list and am trying to include a recursive search. However, I am having trouble understanding how I would go about that. I don't quite understand a recursive search....would any of you be so kind to explain it to me...maybe include some examples. I would GREATLY appreciate it!!!
9
1709
by: Lloyd Sheen | last post by:
For all those who don't think that a recursive search of files in folders is a good thing in the Microsoft.VisualBasic.FileIO.FileSystem namespace listen to this. I am reorg my mp3 collection. I have written my own catalog program and it has xml files to cache info from tags etc. To ensure that the process goes ok I went to delete all the xml files to force a rescan of the tags. This should be simple ..... but this is Vista. So...
5
978
by: Jean-Paul Calderone | last post by:
On Wed, 16 Apr 2008 13:18:22 -0700 (PDT), skanemupp@yahoo.se wrote: Function calls (recursive or otherwise) are more expensive than for loops, so the version that replaces recursion with a loop is faster. Any function can be implemented without recursion, although it isn't always easy or fun. Jean-Paul
0
350
by: Simon Brunning | last post by:
2008/7/4 Gerhard Häring <gh@ghaering.de>: glob's not recursive AFAIK. This recipe probably still works under Pythion 3K, though: <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/499305> -- Cheers, Simon B.
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8586
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.