Retrieving value from function

T

Todd Huttenstine

Below is a function that I got from KeepITKool.

The variable DirSize returns the total size of a specified
directory. The value of this variable is what I am
interested in returning. This function is in a seperate
module than where the code starts executing. What I want
to do is after the function finishes running and then the
code execution moves back into the first module, I want to
access the value of variable DirSize. How do I do this?



Public Function DirSize&(Optional sDir$, Optional sMask$
= "*.*")
Dim n&, sFile$
If sDir = vbNullString Then
sDir = VBA.CurDir$
End If
If VBA.Right$(sDir, 1) <> Application.PathSeparator Then
sDir = sDir & Application.PathSeparator
End If

sFile = VBA.Dir$(sDir & sMask)
While sFile <> vbNullString
n = n + VBA.FileLen(sDir & sFile)
sFile = VBA.Dir$()
Wend

DirSize = n

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top