Solved

DiskFreeSpace

Posted on 2001-08-03
4
158 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now