Solved

DiskFreeSpace

Posted on 2001-08-03
4
157 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

772 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