Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems searching number files

Status
Not open for further replies.

ribhead

Technical User
Jun 2, 2003
384
US
Here is my code and I know it bombs out on the
MyFile= portion. But what is wrong? It seems I'm missing something pretty obvious here? By the way in the combobox I have xls doc ppt and so on.

Sub how_many()
MsgBox NumOfFiles("H:") & " files in your H:"
End Sub

Function NumOfFiles(Path As String) As Long
UserForm1.Show
sext = UserForm1.ComboBox1.Text
Dim MyFile As String
Dim Counter As Long
MyFile = Dir(Path / "*.* & sext")
Do While MyFile <> vbNullString
MyFile = Dir
Counter = Counter + 1
Loop
NumOfFiles = Counter
End Function

For just $19.95 you too can have a beautiful smile.
 
Ahhhhhhhh Thanks a bunch Skip. Since I can't repay you with programming tips if you ever need anybody .... you know... just drop me a line and I'll see what I can do.

For just $19.95 you too can have a beautiful smile.
 
Skip, I can't get this to count the files. I even simplified the search by including all files and taking out the combobox. I noticed that when I step throught it I get an empty string with the MyFile= statement. Any thoughts?
Sub dude()
MsgBox NumOfFiles(&quot;H:&quot;) & &quot; files in H:&quot;
End Sub

Function NumOfFiles(Path As String) As Long
Dim MyFile As String
Dim Counter As Long
MyFile = Dir(Path & &quot; \ *.*&quot;)
Do While MyFile <> vbNullString
MyFile = Dir
Counter = Counter + 1
Loop
NumOfFiles = Counter
End Function

For just $19.95 you too can have a beautiful smile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top