CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2001
    Location
    India
    Posts
    173

    Run Time Error : Urgent

    I have a small project, when I say compile full and run, it runs without any errors, but the same, when made to a EXE file, sometimes, it says "Runtime Error - Procedure/Sub Not Found" but the same is not reported, when U are running the project using VB.

    What is the reasons?????

    Thanks for ur help/suggestions.

    Shivakumar G.M.


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Run Time Error : Urgent

    Runtime errors cannot be trapped at compilation time, so the vb compiler will not find them. What is happening is that you are probably calling a sub or function that doesn't exists, most likely this is happening with an object. If you haven't declared the object, or declared it as object, the compi!ler will not know what type it will be at runtime, so it cannot trap it at compiletime. Let's say you have this code:

    dim rst1
    dim rst2 as object
    dim rst3 as ADODB.Recordset

    set rst0 = CreateObject("ADODB.Recordset")
    set rst1 = CreateObject("ADODB.Recordset")
    set rst2 = CreateObject("ADODB.Recordset")
    set rst3 = CreateObject("ADODB.Recordset")

    rst0.GiveMeDaRecords
    rst1.GiveMeDaRecords
    rst2.GiveMeDaRecords
    rst3.GiveMeDaRecords



    We have 4 recordsets, when calling GiveMeDaRecords, a sub that most definitly doesn't exist for the recordset object, the error is raised. However, when compiling, it will only catch the one of rst3. This is because the compiler can be sure that rst3 is a recordset.
    rst0 isn't declared, so it's a variant, converted to an object by the set
    rst1 is declared as a variant (default type), converted to an object by the set
    rst2 is declared as an object

    because the others aren't declared as a specific type/object, it is impossible for the compiler to predict what type it will be at the time you call a method, so the compiler cannot check if the method exists.
    At run-time however, he will try to call the method of the 'unknown' object, and notice it isn't there, and raise an error.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Run Time Error : Urgent

    I like your explanation, but I am out of votes today.
    Cheers

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Run Time Error : Urgent

    Hmm, youspending to much time with Cimperiali?

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  5. #5
    Join Date
    Aug 2001
    Location
    India
    Posts
    173

    Re: Run Time Error : Urgent

    But, even though I run the project using full compile (i.e., I open VB, then open project and then Run the project) at that time the run time error is not reported, but this happens only when I make it an EXE file and then execute.

    What are the reasons??????

    Thanks,

    Shivakumar G.M.


  6. #6
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Run Time Error : Urgent

    This could be a version conflict, that is when the IDE (VB) takes a newer version of a component than the exe. This could be the case if you have developed your own control/component, and are refferencing the project from vb rather than the dll (or when opening hte project next to the other). In this case, VB will use the project that is open, and not the one that is compiled to dll or ocx. Make sure that you have compiled all components/controls to the latest version.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  7. #7
    Join Date
    Aug 2001
    Location
    India
    Posts
    173

    Re: Run Time Error : Urgent

    I have checked all this and ultimately, I have gone with this
    on error resume next

    till now, this is not giving any problem,

    will it give any?

    Thanks,

    Shivakumar G.M.


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

Featured