CString question
-
Hi, I would like to delete all the characters after ".pvd" in a CString variable. How can I keep all the characters before and including ".pvd" and delete all the characters after it??????? Ehsan Behboudi
-
Hi, I would like to delete all the characters after ".pvd" in a CString variable. How can I keep all the characters before and including ".pvd" and delete all the characters after it??????? Ehsan Behboudi
You use the combination of
Find
andDelete
member functions. An example:CString csText = "I am .pvd and I rock the world !";
csText.Delete( csText.Find(".pvd") + strlen(".pvd"), 4000 );
This code fragment would look for the starting point of the ".pvd", then move forward based on the length of the search string, and delete from this point forwards until 4000 characters are removed or the end of the string is reached (more likely). -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.
-
You use the combination of
Find
andDelete
member functions. An example:CString csText = "I am .pvd and I rock the world !";
csText.Delete( csText.Find(".pvd") + strlen(".pvd"), 4000 );
This code fragment would look for the starting point of the ".pvd", then move forward based on the length of the search string, and delete from this point forwards until 4000 characters are removed or the end of the string is reached (more likely). -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.
-
A quick Win32 console application supporting MFC on the .Net 2003: The code issued for the compiler:
// Create a CString object
CString csText = "I rock the .pdv world !";csText.Delete( csText.Find( ".pdv" ) + (int)strlen(".pdv"), 4000 );
AfxMessageBox( (LPCTSTR) csText, MB_OK );
This code fragment, when run, displays the console window and pops up a message box reading: "I rock the .pdv". Logical conclusion: the code works, and your assumption of it's non-functionality was misplaced. I know your reply comment was meant humorous, but please.. I am tired of fixing things that aren't broken just because there are people in the wide world who think they know better. I don't mean anything malicious with this nor do I want to make you feel bad in any way, but I just don't find it funny. If you believe that you have more accurate information over a matter, present it, and perhaps point out the things that are incorrect in the earlier postings. It's just that this time, I was correct, you were wrong, and the code worked flawlessly and did precise what it was supposed to do. Perhaps next time, the situation will be reversed, and I'll be the one in need of learning new stuff :) -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.