strongd
asked on
Error - Expected Function or Varible
I am trying to get an object to work. It goes out and gets the directory size. Here the code it have so far. Someone Please help me. This is my first object I have created, I have no idea what the problem is...Thanks
Public spath As Class1
Public dtotal As Class1
Private Sub CmdGetSize_Click()
Dim DirectorySize As Class1
Dim spath As String
Dim dtotal As Double
dtotal = 0
spath = Text1.Text
dtotal = 0
dtotal = 0
total = DirectorySize.DirSize(spat h, dtotal)
Text1.Text = DirectorySize
End Sub
Here is Model1 code
Public dtotal As Double
Public spath As String
Here is Class1 code
Public spath As String
Public dtotal As Double
Public Sub DirSize(spath As String, dtotal As Double)
Dim sDir As String
Dim colDir As New Collection
Dim nI As Integer
Dim dLocalTotal As Double
If Right(spath, 1) <> "\" Then spath = spath & "\"
dLocalTotal = 0
' *** Get all the files
sDir = Dir(spath & "*.*", vbArchive + vbDirectory + vbHidden + vbNormal + vbReadOnly + vbSystem)
Do While sDir <> ""
' *** If it is a directory, ignore it
If (GetAttr(spath & sDir) And vbDirectory) <> vbDirectory Then
dLocalTotal = dLocalTotal + FileLen(spath + sDir)
Else
If (Left(sDir, 1) <> ".") Then colDir.Add sDir
End If
sDir = Dir() ' *** Get next entry
Loop
' *** Get all the directorie
For nI = 1 To colDir.Count
Call DirSize(spath & colDir(nI), dLocalTotal)
Next
Set colDir = Nothing
dtotal = dtotal + dLocalTotal
DirSize = dLocalTotal
End Sub
Public spath As Class1
Public dtotal As Class1
Private Sub CmdGetSize_Click()
Dim DirectorySize As Class1
Dim spath As String
Dim dtotal As Double
dtotal = 0
spath = Text1.Text
dtotal = 0
dtotal = 0
total = DirectorySize.DirSize(spat
Text1.Text = DirectorySize
End Sub
Here is Model1 code
Public dtotal As Double
Public spath As String
Here is Class1 code
Public spath As String
Public dtotal As Double
Public Sub DirSize(spath As String, dtotal As Double)
Dim sDir As String
Dim colDir As New Collection
Dim nI As Integer
Dim dLocalTotal As Double
If Right(spath, 1) <> "\" Then spath = spath & "\"
dLocalTotal = 0
' *** Get all the files
sDir = Dir(spath & "*.*", vbArchive + vbDirectory + vbHidden + vbNormal + vbReadOnly + vbSystem)
Do While sDir <> ""
' *** If it is a directory, ignore it
If (GetAttr(spath & sDir) And vbDirectory) <> vbDirectory Then
dLocalTotal = dLocalTotal + FileLen(spath + sDir)
Else
If (Left(sDir, 1) <> ".") Then colDir.Add sDir
End If
sDir = Dir() ' *** Get next entry
Loop
' *** Get all the directorie
For nI = 1 To colDir.Count
Call DirSize(spath & colDir(nI), dLocalTotal)
Next
Set colDir = Nothing
dtotal = dtotal + dLocalTotal
DirSize = dLocalTotal
End Sub
ASKER
Went ahead and did that ClifABB, but I am still getting the same error "Expected function or varible", plus it higlights DirSize in code line total = DirectorySize.DirSize(sPat h, Dtotal). Help?????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way, you still need the 'New' qualifier.
ASKER
Thanks ....
ASKER
Thanks....
Example:
Dim DirectorySize As New Class1