Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Retrieving value from function
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Retrieving value from function
Dim results as Long
results = DirSize("C:\myfolder") msgbox Results -- Regards, Tom Ogilvy "Todd Huttenstine" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Retrieving a document | Excel Worksheet Functions | |||
Retrieving file | Excel Discussion (Misc queries) | |||
retrieving information | Excel Discussion (Misc queries) | |||
Retrieving data | Excel Programming | |||
Retrieving URL | Excel Programming |