Network Drive Free Space

R

ryguy7272

I saw the below code from an old post by Douglas Steele a while back:
Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long

Sub FreeBytes(NetworkShare As String)

Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency


Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Debug.Print " Total Number Of Bytes:", _
Format$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Free Bytes:", _
Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Free Bytes Available:", _
Format$(curBytesFreeToCaller * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Space Used :", _
Format$((curTotalBytes - curTotalFreeBytes) * 10000,
"###,###,###,##0") & " bytes"

End Sub

I popped it into a Module, and tried to call it through a TextBox, but got
nothing. I tried a ListBox; nothing. How do I call use the code?

Thanks,
Ryan---
 
D

Douglas J. Steele

What do you mean by "tried to call it through a TextBox"?

That's a Sub, which means it doesn't return a value if you call it, but you
can't actually call a sub anyhow.
 
R

ryguy7272

In a TextBox I put:
=[GetDiskFreeSpaceEx]

I also added a CommandButton, like this:
Private Sub Command1_Click()
Call FreeBytes
End Sub

I don't understand where the results will go. Does it go into a Table, a
ListBox, a TextBox, a MessageBox?

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


Douglas J. Steele said:
What do you mean by "tried to call it through a TextBox"?

That's a Sub, which means it doesn't return a value if you call it, but you
can't actually call a sub anyhow.
 
J

Jack Leach

The results seem to be printed to the immediate window, and that's it
(through calculations of the cur...Bytes variables). My guess would be that
the cur...Bytes variables are being bassed ByRef, being set in the API, and
then are usable data afterword.

You may want to modify the FreeBytes sub to a function to return the
curFreeBytes value as formatted by Dougs expressions.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



ryguy7272 said:
In a TextBox I put:
=[GetDiskFreeSpaceEx]

I also added a CommandButton, like this:
Private Sub Command1_Click()
Call FreeBytes
End Sub

I don't understand where the results will go. Does it go into a Table, a
ListBox, a TextBox, a MessageBox?

Thanks,
Ryan---
 
R

ryguy7272

Hummm, I thought I tried the Immediate Window before; maybe not though.
Anyway, in Immediate, I entered 'GetDiskFreeSpaceEx' and got 'Compile Error
Argument not Optional'. I tried 'FreeBytes' and got the same result. Did
you get the code to run Jack? What did you do, exactly.

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


Jack Leach said:
The results seem to be printed to the immediate window, and that's it
(through calculations of the cur...Bytes variables). My guess would be that
the cur...Bytes variables are being bassed ByRef, being set in the API, and
then are usable data afterword.

You may want to modify the FreeBytes sub to a function to return the
curFreeBytes value as formatted by Dougs expressions.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



ryguy7272 said:
In a TextBox I put:
=[GetDiskFreeSpaceEx]

I also added a CommandButton, like this:
Private Sub Command1_Click()
Call FreeBytes
End Sub

I don't understand where the results will go. Does it go into a Table, a
ListBox, a TextBox, a MessageBox?

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


Douglas J. Steele said:
What do you mean by "tried to call it through a TextBox"?

That's a Sub, which means it doesn't return a value if you call it, but you
can't actually call a sub anyhow.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I saw the below code from an old post by Douglas Steele a while back:
Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long

Sub FreeBytes(NetworkShare As String)

Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency


Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Debug.Print " Total Number Of Bytes:", _
Format$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Free Bytes:", _
Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Free Bytes Available:", _
Format$(curBytesFreeToCaller * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Space Used :", _
Format$((curTotalBytes - curTotalFreeBytes) * 10000,
"###,###,###,##0") & " bytes"

End Sub

I popped it into a Module, and tried to call it through a TextBox, but got
nothing. I tried a ListBox; nothing. How do I call use the code?

Thanks,
Ryan---
 
J

Jack Leach

I didn't even try to run the code... I just took a look at what you posted
and it appears that the information is being printed to the immediate window
(Doug has a number of lines... debug.print blah blah blah).

The FreeBytes sub requires the argument NetworkShare... the
GetDiskFreeSpaceEx function requires 4 arguments to pass to the API. Of
course you're getting arg not optional if you type only the name and not the
arguments in the immediate window.

The sub FreeBytes doesn't return a value anywhere... not in tables,
textboxes or as a return value for a function... but it does print to the
immediate window through the Debug.Print statement.

So try typing in the immediatewindow:

FreeBytes "networkshare name"

and you should presumably see a list of information printed to the debug
window, per the code that you found.



What I was trying to say before was that you will need to turn FreeBytes
into a function (or make a seperate function) that is capable of returning
the value of cur...Bytes variable(s) rather than merely printing them to the
debug window. Use Dougs examples of formatting when printing to the debug
window for assistance in returning the desired format for your function.


Example:

Public Function fFreeBytes(NetworkShare As String) As Long
Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim cutTotalFreeBytes As Currency

Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

fFreeBytes = Clng(Format$(curTotalFreeBytes * 10000, "###,###,###,##0"))

End Function


and the usage in a textbox:

=fFreeBytes("networksharename")


I haven't tried any of this... btw... just going on the info given, but I
think that's probably what's required to get the value of free bytes into a
textbox (or anything else besides the immediate window).

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



ryguy7272 said:
Hummm, I thought I tried the Immediate Window before; maybe not though.
Anyway, in Immediate, I entered 'GetDiskFreeSpaceEx' and got 'Compile Error
Argument not Optional'. I tried 'FreeBytes' and got the same result. Did
you get the code to run Jack? What did you do, exactly.

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


Jack Leach said:
The results seem to be printed to the immediate window, and that's it
(through calculations of the cur...Bytes variables). My guess would be that
the cur...Bytes variables are being bassed ByRef, being set in the API, and
then are usable data afterword.

You may want to modify the FreeBytes sub to a function to return the
curFreeBytes value as formatted by Dougs expressions.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



ryguy7272 said:
In a TextBox I put:
=[GetDiskFreeSpaceEx]

I also added a CommandButton, like this:
Private Sub Command1_Click()
Call FreeBytes
End Sub

I don't understand where the results will go. Does it go into a Table, a
ListBox, a TextBox, a MessageBox?

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


:

What do you mean by "tried to call it through a TextBox"?

That's a Sub, which means it doesn't return a value if you call it, but you
can't actually call a sub anyhow.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I saw the below code from an old post by Douglas Steele a while back:
Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long

Sub FreeBytes(NetworkShare As String)

Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency


Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Debug.Print " Total Number Of Bytes:", _
Format$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Free Bytes:", _
Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Free Bytes Available:", _
Format$(curBytesFreeToCaller * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Space Used :", _
Format$((curTotalBytes - curTotalFreeBytes) * 10000,
"###,###,###,##0") & " bytes"

End Sub

I popped it into a Module, and tried to call it through a TextBox, but got
nothing. I tried a ListBox; nothing. How do I call use the code?

Thanks,
Ryan---
 
R

ryguy7272

Wow! This is sooooo cool! Everything worked just like you said it would
Jack. I love learning new things.
Thanks for your time!
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


Jack Leach said:
I didn't even try to run the code... I just took a look at what you posted
and it appears that the information is being printed to the immediate window
(Doug has a number of lines... debug.print blah blah blah).

The FreeBytes sub requires the argument NetworkShare... the
GetDiskFreeSpaceEx function requires 4 arguments to pass to the API. Of
course you're getting arg not optional if you type only the name and not the
arguments in the immediate window.

The sub FreeBytes doesn't return a value anywhere... not in tables,
textboxes or as a return value for a function... but it does print to the
immediate window through the Debug.Print statement.

So try typing in the immediatewindow:

FreeBytes "networkshare name"

and you should presumably see a list of information printed to the debug
window, per the code that you found.



What I was trying to say before was that you will need to turn FreeBytes
into a function (or make a seperate function) that is capable of returning
the value of cur...Bytes variable(s) rather than merely printing them to the
debug window. Use Dougs examples of formatting when printing to the debug
window for assistance in returning the desired format for your function.


Example:

Public Function fFreeBytes(NetworkShare As String) As Long
Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim cutTotalFreeBytes As Currency

Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

fFreeBytes = Clng(Format$(curTotalFreeBytes * 10000, "###,###,###,##0"))

End Function


and the usage in a textbox:

=fFreeBytes("networksharename")


I haven't tried any of this... btw... just going on the info given, but I
think that's probably what's required to get the value of free bytes into a
textbox (or anything else besides the immediate window).

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



ryguy7272 said:
Hummm, I thought I tried the Immediate Window before; maybe not though.
Anyway, in Immediate, I entered 'GetDiskFreeSpaceEx' and got 'Compile Error
Argument not Optional'. I tried 'FreeBytes' and got the same result. Did
you get the code to run Jack? What did you do, exactly.

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


Jack Leach said:
The results seem to be printed to the immediate window, and that's it
(through calculations of the cur...Bytes variables). My guess would be that
the cur...Bytes variables are being bassed ByRef, being set in the API, and
then are usable data afterword.

You may want to modify the FreeBytes sub to a function to return the
curFreeBytes value as formatted by Dougs expressions.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



:

In a TextBox I put:
=[GetDiskFreeSpaceEx]

I also added a CommandButton, like this:
Private Sub Command1_Click()
Call FreeBytes
End Sub

I don't understand where the results will go. Does it go into a Table, a
ListBox, a TextBox, a MessageBox?

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


:

What do you mean by "tried to call it through a TextBox"?

That's a Sub, which means it doesn't return a value if you call it, but you
can't actually call a sub anyhow.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I saw the below code from an old post by Douglas Steele a while back:
Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long

Sub FreeBytes(NetworkShare As String)

Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency


Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Debug.Print " Total Number Of Bytes:", _
Format$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Free Bytes:", _
Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Free Bytes Available:", _
Format$(curBytesFreeToCaller * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Space Used :", _
Format$((curTotalBytes - curTotalFreeBytes) * 10000,
"###,###,###,##0") & " bytes"

End Sub

I popped it into a Module, and tried to call it through a TextBox, but got
nothing. I tried a ListBox; nothing. How do I call use the code?

Thanks,
Ryan---
 
J

Jack Leach

Glad to hear it. I was a little curious myself <grin>. I can't recall
seeing a ByRef value used like that before other than in examples (and I
wouldn't have thought you could pass them to an API like that, but it seemed
the only logical thing under the circumstances).

I learned a few things myself, and now I have some code for getting disk
sizing from a network share. Thanks Doug!

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
J

JFree

Jack,

This may be beyond the scope of this thread, but can this code be used in
Excel?

I'm trying to make a spreadsheet that will hold share names in one column
(ie: \\drive\folder\) and in adjacent columns show the total size, space
used, and space available.

I thought I could just drop this code in and call it as a function in Excel
(ie: =fFreeBytes(\\drive\folder) but I am obviously doing it wrong.

Any ideas? And if this is the wrong place for this, I apologize... I'm new
to this.

Thanks,
JFree

Jack Leach said:
I didn't even try to run the code... I just took a look at what you posted
and it appears that the information is being printed to the immediate window
(Doug has a number of lines... debug.print blah blah blah).

The FreeBytes sub requires the argument NetworkShare... the
GetDiskFreeSpaceEx function requires 4 arguments to pass to the API. Of
course you're getting arg not optional if you type only the name and not the
arguments in the immediate window.

The sub FreeBytes doesn't return a value anywhere... not in tables,
textboxes or as a return value for a function... but it does print to the
immediate window through the Debug.Print statement.

So try typing in the immediatewindow:

FreeBytes "networkshare name"

and you should presumably see a list of information printed to the debug
window, per the code that you found.



What I was trying to say before was that you will need to turn FreeBytes
into a function (or make a seperate function) that is capable of returning
the value of cur...Bytes variable(s) rather than merely printing them to the
debug window. Use Dougs examples of formatting when printing to the debug
window for assistance in returning the desired format for your function.


Example:

Public Function fFreeBytes(NetworkShare As String) As Long
Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim cutTotalFreeBytes As Currency

Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

fFreeBytes = Clng(Format$(curTotalFreeBytes * 10000, "###,###,###,##0"))

End Function


and the usage in a textbox:

=fFreeBytes("networksharename")


I haven't tried any of this... btw... just going on the info given, but I
think that's probably what's required to get the value of free bytes into a
textbox (or anything else besides the immediate window).

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



ryguy7272 said:
Hummm, I thought I tried the Immediate Window before; maybe not though.
Anyway, in Immediate, I entered 'GetDiskFreeSpaceEx' and got 'Compile Error
Argument not Optional'. I tried 'FreeBytes' and got the same result. Did
you get the code to run Jack? What did you do, exactly.

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


Jack Leach said:
The results seem to be printed to the immediate window, and that's it
(through calculations of the cur...Bytes variables). My guess would be that
the cur...Bytes variables are being bassed ByRef, being set in the API, and
then are usable data afterword.

You may want to modify the FreeBytes sub to a function to return the
curFreeBytes value as formatted by Dougs expressions.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



:

In a TextBox I put:
=[GetDiskFreeSpaceEx]

I also added a CommandButton, like this:
Private Sub Command1_Click()
Call FreeBytes
End Sub

I don't understand where the results will go. Does it go into a Table, a
ListBox, a TextBox, a MessageBox?

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


:

What do you mean by "tried to call it through a TextBox"?

That's a Sub, which means it doesn't return a value if you call it, but you
can't actually call a sub anyhow.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I saw the below code from an old post by Douglas Steele a while back:
Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long

Sub FreeBytes(NetworkShare As String)

Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency


Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Debug.Print " Total Number Of Bytes:", _
Format$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Free Bytes:", _
Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Free Bytes Available:", _
Format$(curBytesFreeToCaller * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Space Used :", _
Format$((curTotalBytes - curTotalFreeBytes) * 10000,
"###,###,###,##0") & " bytes"

End Sub

I popped it into a Module, and tried to call it through a TextBox, but got
nothing. I tried a ListBox; nothing. How do I call use the code?

Thanks,
Ryan---
 
D

Douglas J. Steele

Unfortunately, this IS the wrong place: it deals with Access, the database
product that's part of Office Professional.

You'd be best off asking in a newsgroup related to Excel.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JFree said:
Jack,

This may be beyond the scope of this thread, but can this code be used in
Excel?

I'm trying to make a spreadsheet that will hold share names in one column
(ie: \\drive\folder\) and in adjacent columns show the total size, space
used, and space available.

I thought I could just drop this code in and call it as a function in
Excel
(ie: =fFreeBytes(\\drive\folder) but I am obviously doing it wrong.

Any ideas? And if this is the wrong place for this, I apologize... I'm
new
to this.

Thanks,
JFree

Jack Leach said:
I didn't even try to run the code... I just took a look at what you
posted
and it appears that the information is being printed to the immediate
window
(Doug has a number of lines... debug.print blah blah blah).

The FreeBytes sub requires the argument NetworkShare... the
GetDiskFreeSpaceEx function requires 4 arguments to pass to the API. Of
course you're getting arg not optional if you type only the name and not
the
arguments in the immediate window.

The sub FreeBytes doesn't return a value anywhere... not in tables,
textboxes or as a return value for a function... but it does print to
the
immediate window through the Debug.Print statement.

So try typing in the immediatewindow:

FreeBytes "networkshare name"

and you should presumably see a list of information printed to the debug
window, per the code that you found.



What I was trying to say before was that you will need to turn FreeBytes
into a function (or make a seperate function) that is capable of
returning
the value of cur...Bytes variable(s) rather than merely printing them to
the
debug window. Use Dougs examples of formatting when printing to the
debug
window for assistance in returning the desired format for your function.


Example:

Public Function fFreeBytes(NetworkShare As String) As Long
Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim cutTotalFreeBytes As Currency

Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

fFreeBytes = Clng(Format$(curTotalFreeBytes * 10000,
"###,###,###,##0"))

End Function


and the usage in a textbox:

=fFreeBytes("networksharename")


I haven't tried any of this... btw... just going on the info given, but I
think that's probably what's required to get the value of free bytes into
a
textbox (or anything else besides the immediate window).

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



ryguy7272 said:
Hummm, I thought I tried the Immediate Window before; maybe not though.
Anyway, in Immediate, I entered 'GetDiskFreeSpaceEx' and got 'Compile
Error
Argument not Optional'. I tried 'FreeBytes' and got the same result.
Did
you get the code to run Jack? What did you do, exactly.

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking
''Yes''.


:

The results seem to be printed to the immediate window, and that's it
(through calculations of the cur...Bytes variables). My guess would
be that
the cur...Bytes variables are being bassed ByRef, being set in the
API, and
then are usable data afterword.

You may want to modify the FreeBytes sub to a function to return the
curFreeBytes value as formatted by Dougs expressions.

hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



:

In a TextBox I put:
=[GetDiskFreeSpaceEx]

I also added a CommandButton, like this:
Private Sub Command1_Click()
Call FreeBytes
End Sub

I don't understand where the results will go. Does it go into a
Table, a
ListBox, a TextBox, a MessageBox?

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking
''Yes''.


:

What do you mean by "tried to call it through a TextBox"?

That's a Sub, which means it doesn't return a value if you call
it, but you
can't actually call a sub anyhow.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


message
I saw the below code from an old post by Douglas Steele a while
back:
Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long

Sub FreeBytes(NetworkShare As String)

Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency


Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Debug.Print " Total Number Of Bytes:", _
Format$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Free Bytes:", _
Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & "
bytes"

Debug.Print " Free Bytes Available:", _
Format$(curBytesFreeToCaller * 10000, "###,###,###,##0") & "
bytes"

Debug.Print " Total Space Used :", _
Format$((curTotalBytes - curTotalFreeBytes) * 10000,
"###,###,###,##0") & " bytes"

End Sub

I popped it into a Module, and tried to call it through a
TextBox, but got
nothing. I tried a ListBox; nothing. How do I call use the
code?

Thanks,
Ryan---
 

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