mfc中怎么将多个编辑框中的内容输入到同一个txt文件中,并用“|”隔开每个编辑框中输入的内容
1个回答
展开全部
关键代码如下
void CMfcdlg2014Dlg::OnButton1() {// TODO: Add your control notification handler code hereCFile f("文本文档.txt", CFile::modeCreate| CFile::modeNoTruncate | CFile::modeWrite);CString s,s1,s2,s3;GetDlgItemText(IDC_EDIT1, s1);GetDlgItemText(IDC_EDIT2, s2);GetDlgItemText(IDC_EDIT3, s3);if(!(s1.GetLength()*s2.GetLength()*s3.GetLength())){MessageBox(_T("请输入完整信息!"));}else{s = s1 + "|" + s2 + "|" + s3 + "\r\n";}f.SeekToEnd();f.Write((LPCTSTR)s, s.GetLength());f.Close();}
void CMfcdlg2014Dlg::OnButton1() {// TODO: Add your control notification handler code hereCFile f("文本文档.txt", CFile::modeCreate| CFile::modeNoTruncate | CFile::modeWrite);CString s,s1,s2,s3;GetDlgItemText(IDC_EDIT1, s1);GetDlgItemText(IDC_EDIT2, s2);GetDlgItemText(IDC_EDIT3, s3);if(!(s1.GetLength()*s2.GetLength()*s3.GetLength())){MessageBox(_T("请输入完整信息!"));}else{s = s1 + "|" + s2 + "|" + s3 + "\r\n";}f.SeekToEnd();f.Write((LPCTSTR)s, s.GetLength());f.Close();}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询