Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DiskFreeSpace

Posted on 2001-08-03
4
Medium Priority
?
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

715 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