Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
im validating email id for that im using this code
void CEMailDlg::OnValidate()
 { 
   // TODO: Add your control notification handler code here 
   CString m_sFrom;
   for(int a=0;a < m_sFrom.GetLength(); a++)
   { 
   if(m_sFrom.GetAt(a) == '@')
   { 
    AfxMessageBox("valid"); 
   }
    else 
   {
   AfxMessageBox("invalid");
   } 
  } 
} 

now the email id is not validating the problem is in this statement
for(int a=0;a < m_sFrom.GetLength(); a++) i think there is problem in "m_sFrom.GetLength();"... i dono what problem it is,, pls help me
Posted
Updated 10-May-11 20:46pm
v2

You need to assign something to m_sFrom.
You are defining it (CString m_sFrom) but it has not been instantiated - thus throwing an error when you try to check the length.
 
Share this answer
 
1. OnValidate should receive as parameter the string variable to be checked OR
2. The string variable should be assigned via a third function OR
3. The string variable should be a global variable out of the function...

Anyway, in your code the variable has no value as it has not been initialized... Therefore it is not possible to iterate it...

What Abhinav S tells you is 100% correct you should avoid checking the string if the minimum requirements are not fulfilled...

HTH...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900