Results 1 to 9 of 9

Thread: Invalid property value

  1. #1

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692

    Invalid property value

    Why do I get an invalid property value on this line?

    VB Code:
    1. pbrProgress.Value = pbrProgress.Value + thisFile.Size

    thisFile is dimmed as a File.

    Here's the whole function in case.

    VB Code:
    1. Sub ScanFolder(FolderSpec)
    2.     Dim thisFolder As Folder
    3.     Dim allFolders As Folders
    4.     Dim thisFile As File
    5.     Dim allFiles As Files
    6.     Dim TotalCDSize As Long
    7.     Dim i As Integer
    8.     Dim x As Integer
    9.     Dim rs As ADODB.Recordset
    10.     Set rs = New ADODB.Recordset
    11.     Set fso = New FileSystemObject
    12.     rs.Open dtaVolumes.RecordSource, dtaVolumes.ConnectionString, adOpenKeyset, adLockOptimistic
    13.     Set thisFolder = fso.GetFolder(FolderSpec)
    14.     Set allFolders = thisFolder.SubFolders
    15.     For Each thisFolder In allFolders
    16.         If (thisFolder.Attributes And Hidden) <> Hidden Then
    17.             Set allFiles = thisFolder.Files
    18.             If allFiles.Count > 0 Then
    19.                 For Each thisFile In allFiles
    20.                     TotalCDSize = TotalCDSize + thisFile.Size
    21.                 Next
    22.                 pbrProgress.Max = TotalCDSize
    23.                 For Each thisFile In allFiles
    24.                     rs.AddNew
    25.                     rs!Files = thisFile.Name
    26.                     pbrProgress.Value = pbrProgress.Value + thisFile.Size
    27.                 Next
    28.             End If
    29.             Set allFiles = Nothing
    30.             ScanFolder thisFolder.Path
    31.         End If
    32.         DoEvents
    33.     Next
    34.     Set thisFolder = Nothing
    35.     Set allFolders = Nothing
    36.     Set rs = Nothing
    37.     Set fso = Nothing
    38.     Exit Sub
    39.     Unload Me
    40. End Sub

  2. #2
    Member
    Join Date
    Apr 2004
    Location
    Chennai,India
    Posts
    40
    Please put break-point and check whether pbrProgress.Max value exceeds after executing this line.

  3. #3

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    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.

  4. #4
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    I would suggest to make the max 100, and calculate a percentage instead.

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109
    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.

  6. #6

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    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?

  7. #7
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    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.

  8. #8

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692
    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?

  9. #9
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Yes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width