Line by line debugging works but built execution (EXE) does not

I have a Visual Basic code running in company with Catia V5 R14 SP4. My development kit is MS Visual Studio 6.0 installed on Windows XP SP2.

It reads model file names in iteration from an Excel worksheet and then opens the model in Catia V5. Next, it changes some properties of the model and then closes it after saving. This iteration goes on until all Excel lines are processed.

When I run the code line by line in debugging mode, it works fine and does the job. No errors.

However, when I compiled this code into an EXE, it does not work properly. After a few iterations, an empty Catia V5 window appears with name "CATFrmWindow". In the meantime, the EXE continues but at a point Catia V5 gives "Command Interrupted" error and crashes.

Any ideas why the EXE would behave differently than the line-by-line execution?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Perhaps the exe is going to fast for your catia...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TAI-Author Commented:
Thank you Dhaest,

Although I was expecting a more complex solution, it seems that the correct answer is this one. Indeed, that was also our comment on the problem because the only difference is "time".

To be more precise in my expectation:
What I have found is that Catia V5 cannot complete some jobs before saving. However, I don't want to put a trivial period of pause in front of the save (e.g. 2 minutes). It's because there are around 2500 files of different sizes and it is essential that execution is fast.

I want to be able to check whether Catia V5 completed its job before any save operation.
Any methods to check it?

(I will keep it open for a more complex solution.)
I don't know Catia V5, so I don't know if there is a possibilty to check if it's completed his jobs...
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

do you use shell to start catia?
You could also make a control program which launches 2500 the program
if the executable can run next to each other that is.
then your iteration is in the control program and the program you now have only processes one excel file
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Shy of actually installing VB Enterprise on that pc, the manual way of pulling this off would be to insert various msgbox's in code where you believe it to be failing, compile, deploy, run, and see which msgbox's display and which do not.   Either that, or writing comments to a text file.

Sorry, but not a world of options here.
TAI-Author Commented:
Thank you Jimhorn,

As I wrote in my reply to Dhaest's comment; I was aware that the problem is the most probably "time". Therefore, I had some "pauses" in between the lines of code. And eventually, as I wrote above, I found the problem "Catia V5 cannot complete the jobs before VB saves the model file." (Yesterday I was not so sure but today no doubt.)

So I need a function that recognizes Catia is done or that checks if the previous line of code was "thoroughly" completed both on VB and on Catia.

If there is no such function (at least I don't know) it's OK and I will need to choose "pauses" giving up the performance.

All the best,
I don't know the program, so I'm not sure that it is possible. Isn't there any programming reference deliverd with the program (or perhaps on the net).
You can perhaps also ask them if there is a programming reference. If not, then you 'll have to work with pauses...
Hi Tai...

If I get this right... just to simplify your program is talking to another but when compiled is running too fast going from one instruction to the next, which causes an error?  If the error is trappable I would try this

Dim waitDate as Date, success As Boolean

'Do Job 1... what ever that is here


waitDate = DateAdd("S",15,now)

On Err Resume Next
While now<waitDate And success=False
  'Call Job2 here

  If Err = 0 Then
  End If
On Err Goto 0

Is that any good?
TAI-Author Commented:
Hello Dhaest,

Unfortunately, the references do not provide such a method and I had to utilize a "pause" routine.
Thank you for your idea on "speed", which leads to "time"  ;)

Hello Dentab,

It seems that your code does the opposite of what I wanted; but the general idea is the same. Parallel to this, I had used a selt-written "pause" sub.

As far as I understand your code:
- Since Catia V5 does not give an explicit error in this case, "Err" does not work as you expected.
- For me Job2 is "to save", therefore itmust be after the "While" loop. I mean,

   While now < waitDate
   Catia.Save  'Job2

Thank you all for giving ideas,

It does the opposite?

It should br trying untill its ok.  If I knew thet Err didn't work I would have looked for the general error trapping alternative.  There are other answers too but a short delay seems like a reasonable solution.  At least I have this months points quota so no real loss, as long as your problem is solved.
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the split, good luck with your project.  -Jim

btw "lose" all the "double" "quotes" in your "comments".  TIA.
TAI-Author Commented:
Hello Jimhorn,

I usually use double quotes to distinguish system/software messages and to emphasize important words.

Although I think that I used them properly in my way, it seems that you found them too many.
I am open to your critics and will be glad to hear your further comments. Especially if you think that they make reading & understanding my messages more difficult.

Hi Tai,

I think its a useful notation, prehaps if you used asterisks instead?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.