MFC中验证电子邮件ID时出现问题 [英] problem in validating email id in MFC

查看:73
本文介绍了MFC中验证电子邮件ID时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


即时通讯使用此代码验证该即时通讯的电子邮件ID


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");
   } 
  } 
} 


现在,电子邮件ID无法验证问题是否在此语句中
for(int a = 0; a& lt; m_sFrom.GetLength(); a ++)我认为"m_sFrom.GetLength();"中存在问题……我不知道这是什么问题,请帮助我


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

推荐答案

您需要为m_sFrom分配一些内容.
您正在定义它(CString m_sFrom),但尚未实例化-因此,当您尝试检查长度时会引发错误.
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.


1. OnValidate应该接收要检查的字符串变量作为参数,或者
2.字符串变量应通过第三个函数OR
赋值 3.字符串变量应该是函数之外的全局变量...

无论如何,在您的代码中,该变量没有值,因为尚未初始化...因此无法对其进行迭代...

Abhinav S告诉您的内容是100%正确的,如果未满足最低要求,则应避免检查字符串...

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


这篇关于MFC中验证电子邮件ID时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆