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?
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?
0
 
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.
0
 
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.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
mtipsAuthor Commented:
Hi
Im not to hot on C++ where would this code go?
Thanks
0
 
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.
0
 
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();
0

Experts Exchange Solution brought to you by ConnectWise

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