|
-
Apr 27th, 2004, 10:28 PM
#1
Thread Starter
Fanatic Member
Invalid property value
Why do I get an invalid property value on this line?
VB Code:
pbrProgress.Value = pbrProgress.Value + thisFile.Size
thisFile is dimmed as a File.
Here's the whole function in case.
VB Code:
Sub ScanFolder(FolderSpec)
Dim thisFolder As Folder
Dim allFolders As Folders
Dim thisFile As File
Dim allFiles As Files
Dim TotalCDSize As Long
Dim i As Integer
Dim x As Integer
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set fso = New FileSystemObject
rs.Open dtaVolumes.RecordSource, dtaVolumes.ConnectionString, adOpenKeyset, adLockOptimistic
Set thisFolder = fso.GetFolder(FolderSpec)
Set allFolders = thisFolder.SubFolders
For Each thisFolder In allFolders
If (thisFolder.Attributes And Hidden) <> Hidden Then
Set allFiles = thisFolder.Files
If allFiles.Count > 0 Then
For Each thisFile In allFiles
TotalCDSize = TotalCDSize + thisFile.Size
Next
pbrProgress.Max = TotalCDSize
For Each thisFile In allFiles
rs.AddNew
rs!Files = thisFile.Name
pbrProgress.Value = pbrProgress.Value + thisFile.Size
Next
End If
Set allFiles = Nothing
ScanFolder thisFolder.Path
End If
DoEvents
Next
Set thisFolder = Nothing
Set allFolders = Nothing
Set rs = Nothing
Set fso = Nothing
Exit Sub
Unload Me
End Sub
-
Apr 28th, 2004, 01:04 AM
#2
Member
Please put break-point and check whether pbrProgress.Max value exceeds after executing this line.
-
Apr 28th, 2004, 04:48 PM
#3
Thread Starter
Fanatic Member
Inserting the breakpoint, I did a Debug.Print on pbrProgress.Max, and it turned out to have a value of 5,455,526. I can't do this on pbrProgress.Value because VB locks up. (I switched tasks between IE and VB) DoEvents should fix this, right?
Last edited by hothead; Apr 28th, 2004 at 05:01 PM.
-
Apr 28th, 2004, 05:05 PM
#4
The picture isn't missing
I would suggest to make the max 100, and calculate a percentage instead.
-
Apr 28th, 2004, 05:06 PM
#5
Put a messagebox into the code to show the value just before you are going to use it. That ought to tell you what you need to know.
-
Apr 28th, 2004, 07:09 PM
#6
Thread Starter
Fanatic Member
Originally posted by BuggyProgrammer
I would suggest to make the max 100, and calculate a percentage instead.
So noted. Percentage is calculated by dividing the total size of all files on the CD by the amount of data processed, correct?
-
Apr 28th, 2004, 10:53 PM
#7
The picture isn't missing
Originally posted by hothead
So noted. Percentage is calculated by dividing the total size of all files on the CD by the amount of data processed, correct?
Yes.
-
Apr 29th, 2004, 05:22 PM
#8
Thread Starter
Fanatic Member
One more problem.
Why does VB lock up when I try to debug the program after getting an error? Is it because I'm subclassing, and have the form hooked?
-
Apr 29th, 2004, 06:19 PM
#9
The picture isn't missing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|