Try this:
Sub Demo()
MsgBox FileCountA("C:\temp\")
MsgBox FileCountB("C:\temp\")
End Sub
Function FileCountA(Path As String) As Long
Dim strTemp As String
Dim lngCount As Long
strTemp = Dir(Path & "*.*")
Do While strTemp <> ""
lngCount = lngCount + 1
strTemp = Dir
Loop
FileCountA = lngCount
End Function
Function FileCountB(Path As String) As Long
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject").GetFolder(Path)
FileCountB = objFSO.Files.Count
Set objFSO = Nothing
End Function
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
"Alex Dybenko" wrote:
> Hi,
> something like this:
>
> strFile = dir("c:\*.*")
> do while len(strFile)>0
> I=I+1
> strFile=dir
> loop
>
> debug.print I
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://accessblog.net
> http://www.PointLtd.com
>
>
> "Jim" <(E-Mail Removed)> wrote in message
> news:104A3781-C5E1-446A-80B1-(E-Mail Removed)...
> > I’m sorry if this is a repost, I posted the same question yesterday but it
> > never appeared on the site.
> >
> > Could someone please show me an example or examples of how to return the
> > number of files in a folder? I don’t need anything except the total
> > number
> > of files in the folder. I’d like to use VB but, I’m open to any solution…
> >
> > Thanks in advance,
> >
> > Jim
> >
> >
> .
>