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
Re: Run Time Error : Urgent
I like your explanation, but I am out of votes today.
Cheers
Iouri Boutchkine
[email protected]
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
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.
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
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.