dcsimg
Results 1 to 12 of 12

Thread: [RESOLVED] run time error 424 object required VB6

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Resolved [RESOLVED] run time error 424 object required VB6

    I have a program which runs fine inside vb6, even when i click run with full compile it runs with no errors. but when i actually compile it and then double click the .exe i get run time error 424 object required. i read somewhere that this might be due to library references going bad or something. how can i fix this?

  2. #2

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: run time error 424 object required VB6

    Theres only 1 form, no modules, option explicit is turned on in this form.
    It runs fine in the IDE when i run it with full compile, it's when i compile it to an .exe and run it outside the IDE that it gets this problem

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,778

    Re: run time error 424 object required VB6

    which part gives the error?
    if you can not tell when it errors you need to write a log file, so you can tell when it fails
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: run time error 424 object required VB6

    i don't know what part fails because it doesn't tell me but i am thinking it is somewhere in this reigon of code:

    Code:
    Text1.Text = "Scanning..."
    DoEvents
    findFiles (objFSO.GetFolder("C:\Program Files"))
    i think it is in this reigon because text1 says scanning... and then the error happens

  6. #6

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: run time error 424 object required VB6

    yes, objfso is set and initialized, in my declarations i have:
    Dim objFSO As Object
    and in form load i have:
    Set objFSO = New FileSystemObject

    findfiles does this:

    Code:
    Public Sub findFiles(oFolder As Folder)
    On Error Resume Next
    
        For Each oFile In oFolder.Files 'Loop through the files.
    list1.additem ofile.path
        Next oFile
    For Each oSub In oFolder.SubFolders                     'Loop through the subfolders.
        Call findFiles(objFSO.GetFolder(oSub)) 'Recurse this function.
        Next oSub
        Exit Sub
    End Sub

  8. #8

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: run time error 424 object required VB6

    yeah, i declared them in the declarations section:
    Dim oSub As Folder, oFile As File

  10. #10

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    528

    Re: run time error 424 object required VB6

    It's ok now, i found it.
    it's because i needed to do:
    Call findFiles(objFSO.GetFolder("C:\Program Files\"))
    instead of
    findFiles(objFSO.GetFolder("C:\Program Files\"))

    and because findfiles needed to be private sub instead of public sub

  12. #12
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: [RESOLVED] run time error 424 object required VB6

    I'm glad it is working for you but it really makes no sense:

    1.
    Call findFiles(objFSO.GetFolder("C:\Program Files\"))
    and
    findFiles objFSO.GetFolder("C:\Program Files\")

    are practically the same

    2.
    Procedure scope can be private or public.



    You could've used this instead because you're calling that procedure recirsively:
    Code:
    For Each oSub In oFolder.SubFolders
        findFiles objFSO.GetFolder(oSub.Path)
        'or
        findFiles oSub.Path
    Next oSub

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width