Hi All !(CString Class)
-
How can alow the user to enter only numbers lets say with "4" into CEditBox ! for ex: 41,42,411,42222 !!!!!! i have tried this : CString sCod; m_cod.GetWindowText(sCod); if(!sCod.Left(1).Compare("4")) { //something } else { AfxMessageBox("Incorect number"); } but is not working ! please help me !
Bravoone
First of all, I haven´t found a Left member inside the CString class :confused: I would do that way: char sCod[20]; strcpy(sCod,m_cod.GetWindowText()); if (strcmp(sCod[0],"4")==0) { //Here write your code } else { MessageBox("Incorrect number"); } I hope it may help you! Good luck from Bilbao! (SPAIN) :-D
-
How can alow the user to enter only numbers lets say with "4" into CEditBox ! for ex: 41,42,411,42222 !!!!!! i have tried this : CString sCod; m_cod.GetWindowText(sCod); if(!sCod.Left(1).Compare("4")) { //something } else { AfxMessageBox("Incorect number"); } but is not working ! please help me !
Bravoone
all i want is to enter only numbers that have 4 first number for example 48956687 the first number is 4 !!!!!! Thank you !
Bravoone
-
First of all, I haven´t found a Left member inside the CString class :confused: I would do that way: char sCod[20]; strcpy(sCod,m_cod.GetWindowText()); if (strcmp(sCod[0],"4")==0) { //Here write your code } else { MessageBox("Incorrect number"); } I hope it may help you! Good luck from Bilbao! (SPAIN) :-D
-
First of all, I haven´t found a Left member inside the CString class :confused: I would do that way: char sCod[20]; strcpy(sCod,m_cod.GetWindowText()); if (strcmp(sCod[0],"4")==0) { //Here write your code } else { MessageBox("Incorrect number"); } I hope it may help you! Good luck from Bilbao! (SPAIN) :-D
i have 2 errors to your code : 1)error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters 2)error C2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char *' what is wrong ?
Bravoone
-
Gosh!! Next time remember me to write the name of the function like this "Left" and not like this "left". I´m really ashamed... :doh: :laugh:
-
How can alow the user to enter only numbers lets say with "4" into CEditBox ! for ex: 41,42,411,42222 !!!!!! i have tried this : CString sCod; m_cod.GetWindowText(sCod); if(!sCod.Left(1).Compare("4")) { //something } else { AfxMessageBox("Incorect number"); } but is not working ! please help me !
Bravoone
Nope nothing,nothing is working i don t know what to do ! The first number in the string must be 4 ! this is a serious problem i dont expect to be so hard !
Bravoone
-
Nope nothing,nothing is working i don t know what to do ! The first number in the string must be 4 ! this is a serious problem i dont expect to be so hard !
Bravoone
If you want to let the user only enter the number's that start with 4 you would need to override the EN_CHANGE notification. When the user hits anything except a 4 for the first time just discard the value else continue. I hope I do get you correctly now and this helps you.
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
Nope nothing,nothing is working i don t know what to do ! The first number in the string must be 4 ! this is a serious problem i dont expect to be so hard !
Bravoone
void CBravooneTest::OnEnChangeEdit1() { CString str; if(((CEdit*)GetDlgItem (IDC_EDIT1))->GetWindowTextLength()>0){ ((CEdit*)GetDlgItem(IDC_EDIT1))->GetWindowText (str); if(str.GetAt(0)!='4') ((CEdit*)GetDlgItem(IDC_EDIT1))->SetWindowText(""); } }
See if this is what you need.
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
How can alow the user to enter only numbers lets say with "4" into CEditBox ! for ex: 41,42,411,42222 !!!!!! i have tried this : CString sCod; m_cod.GetWindowText(sCod); if(!sCod.Left(1).Compare("4")) { //something } else { AfxMessageBox("Incorect number"); } but is not working ! please help me !
Bravoone
-
Nope nothing,nothing is working i don t know what to do ! The first number in the string must be 4 ! this is a serious problem i dont expect to be so hard !
Bravoone
Hi Bravoone, I have a hardware question do you know about DVD players?
WhiteSky