Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DiskFreeSpace

Posted on 2001-08-03
4
Medium Priority
?
169 Views
Last Modified: 2011-10-03
How do i get the free space of a server on the network?
(It demands a password)

Second ,  i saw many times a $ sign after a name of a variable , what is it for?
0
Comment
Question by:itzikb
  • 2
4 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6350613
a $ sign after the name hard sets the variable to a string

Dim x

x$ = "This is a string"

So essentially, x was dimmed as a variant.  Then forcing it to become a string data type.  There are others for other datatypes, but I'd have to look them up... Some people use them for no apparent reason...

Dim x as string

x$ = "This is a string"

"This is stupid"
0
 
LVL 3

Expert Comment

by:andysalih
ID: 6350621
this will get all the information you require, but im note sure about the password side,

there will be full source code including in file.

download from

http://www.planetsourcecode.com/xq/ASP/txtCodeId.25033/lngWId.1/qx/vb/scripts/ShowCode.htm

also like prev stated

$ defines var as string

visual basic = dim var as string

basic or others = var$="anything"

denotes var can store numbers or words "string"



hope this helps

Andy
0
 
LVL 3

Accepted Solution

by:
andysalih earned 400 total points
ID: 6350626
or you could use this code, you will need to encorperate the password side in yourself.

General Declarations of Module:
'Example
'Cur_X = DiskFree("C:")
'You can use Str_Z = Format(Cur_X,"#,0")
'     to put the commas in (eg. 1,234,567)
'if Cur_X = 0 then get DiskFree failed.


Declare Function GetDiskFreeSpace_FAT16 Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
    Dim SectorsPerCluster&, BytesPerSector&, NumberOfFreeClusters&, TotalNumberOfClusters&


Declare Function GetDiskFreeSpace_FAT32 Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, FreeBytesToCaller As Currency, BytesTotal As Currency, FreeBytesTotal As Currency) As Long
    Dim FreeBytesAvailable@, TotalBytes@, TotalFreeBytes@
             
' Inputs:Drive - Type String in the foll
'     owing format "X:" X = drive letter
'
' Returns:Disk Space Free returned as va
'     lue Currency.




Public Function DiskFree(Drive As String) As Currency
    Passed = GetDiskFreeSpace_FAT16(Drive, SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters)


    If Passed = 0 Then 'Not FAT16, Try FAT32
        Passed = GetDiskFreeSpace_FAT32(Drive, FreeBytesAvailable, TotalBytes, TotalFreeBytes)


        If Passed = 0 Then
            'getinfo failed, return 0, exit sub
            DiskFree = 0
            Exit Function
        End If
        DiskFree = CCur(FreeBytesAvailable) 'FAT32
        Exit Function
    End If
    DiskFree = CCur(NumberOfFreeClusters * SectorsPerCluster * BytesPerSector) 'FAT16
End Function


hope this helps my friend

cheers
Andy
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6350732
Further clarification on the "$"

"$" is the old QuickBASIC way of defining a string and was typically put in the dim statement (if the dim statement was used):

Dim A$

is identical to the "newer" (and much clearer)

Dim A as String

--
Also, $ is often used with various functions (Left$, Str$, etc.)  In this case, the results are the same as their counter-parts without the $ (Left, Str, etc.), but (I'm told) the ones with the $ are much faster becauses they explicitly use string for their caluclations rather than the slower variants.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question