Wildcard???

bgcogen

Registered User.
Local time
Today, 20:49
Joined
Apr 19, 2002
Messages
61
Hi!
Basically I have to import a number of files from a directory in the C: drive. All of the files have a standard form, for which I've written code to loop through the folder.
But now the files will be having a five digit random number added onto the end of their names. I've tried writing:

Importfile = "Standard_name_part" & * & ".dat"

and

Importfile = "Standard_name_part" & "*" & ".dat"

But the compiler doesn't recognise the * symbol. What can I do???

Thanks,
D
 
Ok to create a random number use this

Dim MyValue as Integer
Randomize
MyValue = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.

Istead of using Importfile = "Standard_name_part" & "*" & ".dat"

use

Importfile = "Standard_name_part" & MyValue & ".dat"

Search the help file on Rnd to learn about Random numbers.

htp
 
Sorry, I probably didn't explain properly.

I don't want to add a random number to the file names. The new files that are sent to our company will have a random number attached to them [as far as we're concerned].

What I need to do is for VB to loop through all the files in the folder, importing each files. I want to use the * character to basically say - " Import all files that have this standard format, and any 5 digits on the end."

I have the loop working OK. I just need to add the WC character to the end.

Thanks,
D :cool:
 
Got you!!

You can't have a wild card in the middle of a string, the wild card is looking for any characters after the first part, so it will ignore the .dat.

# will find any single number, so try Importfile = "Standard_name_part" & "#####" & ".dat"

hth
 

Users who are viewing this thread

Back
Top Bottom