Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving a document mu74grad Excel Worksheet Functions 1 November 10th 07 03:25 AM
Retrieving file Darlene Excel Discussion (Misc queries) 1 April 24th 07 02:14 AM
retrieving information hsb101 Excel Discussion (Misc queries) 1 August 3rd 06 09:15 AM
Retrieving data Alan M[_2_] Excel Programming 5 March 24th 05 12:27 PM
Retrieving URL ChuckS Excel Programming 0 November 6th 03 09:31 PM


All times are GMT +1. The time now is 06:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"