Click to See Complete Forum and Search --> : Run Time Error : Urgent


Shiv Kumar G.M.
September 20th, 2001, 06:28 AM
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.

Cakkie
September 20th, 2001, 08:38 AM
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
slisse@planetinternet.be

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

Iouri
September 20th, 2001, 10:51 AM
I like your explanation, but I am out of votes today.
Cheers

Iouri Boutchkine
iouri@hotsheet.com

Cakkie
September 20th, 2001, 11:24 AM
Hmm, youspending to much time with Cimperiali?

Tom Cannaerts
slisse@planetinternet.be

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

Shiv Kumar G.M.
September 20th, 2001, 11:01 PM
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.

Cakkie
September 21st, 2001, 01:27 AM
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
slisse@planetinternet.be

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

Shiv Kumar G.M.
September 22nd, 2001, 06:01 AM
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.