|
-
May 5th, 2004, 06:25 PM
#1
Thread Starter
Fanatic Member
Serious bug, need help fixing. [SOLVED]
Take a look at the following code snippets.
VB Code:
Private Sub ScanFolder(FolderSpec)
Dim ThisFolder As Folder
Dim AllFolders As Folders
Dim ThisFile As File
Dim AllFiles As Files
Dim i As Integer
Set fso = New FileSystemObject
If Not Len(FolderSpec) = 1 Then
Set ThisFolder = fso.GetFolder(FolderSpec & "\")
Else
Set ThisFolder = fso.GetFolder(FolderSpec & ":")
End If
Set AllFolders = ThisFolder.SubFolders
For Each ThisFolder In AllFolders
Set AllFiles = ThisFolder.Files
If AllFiles.Count > 0 Then
For Each ThisFile In AllFiles
Set lstItem = frmMain.lvwFileList.ListItems.Add(, , ThisFile.Path)
lstItem.SubItems(1) = ThisFile.Size
Next
End If
Set AllFiles = Nothing
ScanFolder ThisFolder.Path
DoEvents
Next
Set ThisFolder = Nothing
Set AllFolders = Nothing
Set fso = Nothing
Set lstItem = Nothing
Unload Me
End Sub
Private Sub Form_Activate()
Dim drv As Drive
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
KeepOnTop Me
CenterForm Me
Response = InputBox("Enter a label for this volume.", "Enter volume label")
rs.Open dtaVolumes.RecordSource, dtaVolumes.ConnectionString, adOpenKeyset, adLockOptimistic
Set fso = New FileSystemObject
For Each drv In fso.Drives
If drv.DriveType = CDRom Then
If drv.IsReady = True Then
ScanFolder drv.DriveLetter
Else
Exit Sub
End If
End If
Next
For i = 1 To frmMain.lvwFileList.ListItems.Count
TotalCDSize = TotalCDSize + frmMain.lvwFileList.ListItems(i).SubItems(1)
rs.AddNew
rs!Name = Response
rs!Date_Created = Date
rs!Files = frmMain.lvwFileList.ListItems(i)
Next i
For i = 1 To frmMain.lvwFileList.ListItems.Count
BytesProcessed = BytesProcessed + frmMain.lvwFileList.ListItems(i).SubItems(1)
pbrProgress.Value = BytesProcessed / TotalCDSize
Next i
Set lstItem = frmMain.lvwVolumes.ListItems.Add(, , Response)
lstItem.SubItems(1) = Date
lstItem.SubItems(2) = frmMain.lvwFileList.ListItems.Count
frmMain.lvwFileList.ListItems.Clear
Set fso = Nothing
Set rs = Nothing
Set lstItem = Nothing
End Sub
My problem is this: When the code is as it stands right now, the program works fine, but of course the progress bar won't run because of the Unload Me in the ScanFolder sub. However, if I put the Unload Me in the Form_Activate event, the code runs multiple times, and eventually errors out with an unspecified error when it executes the rs.Open procedure.
When I step through the code one line at a time, the code works like it's supposed to with Unload Me in the Form_Activate event.
I can't put it in the Form_Load event either, else frmSetup doesn't show until the entire procedure is finished.
Last edited by hothead; May 6th, 2004 at 08:29 PM.
-
May 5th, 2004, 08:00 PM
#2
Member
I can't put it in the Form_Load event either, else frmSetup doesn't show until the entire procedure is finished
I ran into a little problem like this and I don't know exactly how i fixed it . Try a frmSetup.refresh at the start of the form load then a few doevents, or frmSetup.visible = true. (Hope it works)
Dave 
-
May 6th, 2004, 07:58 PM
#3
Thread Starter
Fanatic Member
It's fixed, thanks a lot.
Last edited by hothead; May 6th, 2004 at 08:28 PM.
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
|