IF problem in C++

I've a problem with this IF sentence in Visual Studio 2010 C++:
      if (dataAligV!=0)
      {
            objPT=frmPH-objPT;
      }

If I run the program in Debug Mode it works fine and does'nt execute the "objPT=" sentence but in release mode (with the same input data)  it doesn't work.

In release mode, if I add some code to do a txt trace, it also works fine. I know it could be a hard issue to solve, but I would appreciate if anyone can help me.

tks in advance,
Leonel
samplecode.txt
leorochaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
n2fcConnect With a Mentor Commented:
If the results vary like that, probable cause is an uninitialized variable...

Try setting an initial value for "dataAligV" when you declare it...
0
 
Julian HansenCommented:
So you are saying if you put something here
 if (dataAligV!=0)
      {
            objPT=frmPH-objPT;
   // Dump dataAligV here
      }

Open in new window

It works the way you want to?
0
 
leorochaAuthor Commented:
Yes, JulianH. Also if no code is inserted but in DEBUG MODE works fine. The problem arises when I build the code in RELEASE MODE. It's hard to solve...

For more info, it is a WIN32 project creating "int __stdcall fnCreateCardEx" and exporting to be used by an VB6 ActiveX. This function do some graphic printing over plastic cards using WINGDI
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
leorochaAuthor Commented:
n2fc, I've checked that a hundred times (but I'will do this again). All variables are initialized.
0
 
leorochaAuthor Commented:
tks n2fc, in 101 try I've found the problem. The variable was initialized but not in the correct way in VB6 ActiveX
0
 
n2fcCommented:
Glad I was able to help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.