views:

163

answers:

1

Hi there. Im having a problem with a loop inside a C++ dll being called from VB. I want this loop to update a global variable, but when I call the function the variable does not update the first time round, but does so every subsequent time.

This is how I am trying to update the variable.

else 
{
   ::nScore = nHighest;

    if (nScore != 0)
    {
       ::nColourOn++;    
    }
}

As a workaroud I am forcing the variable to be what I want in the VB code, but am not happy with this solution. Does anyone have any idea what might be causing this?

Many Thanks.

+1  A: 

If the value of nHighest isn't initialized, nScore will be 0 and nColorOn won't be incremented. Is that the error you're seeing? If so, set nHighest, otherwise, it's working fine. :)

overslacked