C++ Edit Box Validation

Hi......I am designing a database which shows all the records. The records can be updated using a dialog box. I have added a validation to one of the edit fields so it can only use ints but when i try to shw the results on the main form i get the error:
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class CString' (or there is no acceptable conversion)
The code im using is:
void CAssignment2View::OnButton1()
{      
        CNewDlg d;      
      int nRet = -1;    
      if( nRet = d.DoModal() )    
      {                            
            switch ( nRet )  
            {   case -1:      
            AfxMessageBox("Error - Please Restart Program");  
            break;    
            case IDOK:
            UpdateData();
m_pSet->m_RegNo = d.m_RegNo;  
       d.m_RegNo = m_pSet->m_RegNo;
       UpdateData(FALSE);
        m_pSet->Update();
mtipsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

jkrCommented:
How are the cariable you are using declared?
mtipsAuthor Commented:
The first form RegNo is Cstring as the information is  characters as the database info is characters
The dialog box regNo is int as the info must be changed to ints
I have tried changing the first form regNo as a int but it keeps changing back to Cstring on its own.
jkrCommented:
Well, then you might need to convet it, e.g.

CString tmp;
tmp.Format("%d",d.m_RegNo);
m_pSet->m_RegNo = tmp;  
d.m_RegNo = atoi(m_pSet->m_RegNo);

You'll need to

#include <stdlib.h>

for the above.
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

mtipsAuthor Commented:
Hi
Im not to hot on C++ where would this code go?
Thanks
mtipsAuthor Commented:
I have put it in place of the Original RegNo piece of code but an error occurs saying that tmp is skipped by case and default labels.
jkrCommented:
>>where would this code go?

The same place as in yours above, i.e.


#include <stdlib.h>

void CAssignment2View::OnButton1()
{    
       CNewDlg d;      
     CString tmp;
     int nRet = -1;    
     if( nRet = d.DoModal() )    
     {                            
          switch ( nRet )  
          {   case -1:      
          AfxMessageBox("Error - Please Restart Program");  
          break;    
          case IDOK:
          UpdateData();
      tmp.Format("%d",d.m_RegNo);
      m_pSet->m_RegNo = tmp;  
      d.m_RegNo = atoi(m_pSet->m_RegNo);
      UpdateData(FALSE);
       m_pSet->Update();

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
mtipsAuthor Commented:
Cheers thanks alot for that ive got it working now great stuff.
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
C++

From novice to tech pro — start learning today.