CString.Remove()

I'm working in VC++ .Net 2003 with a Unicode project.
I have a CString object that I want to remove a phrase from that is stored 
in another CString object. I have looked at the function CString.Remove() but 
I cannot get this thing to work. It seems to require a datatype called XCHAR, 
so I have tried to convert my second CString object into something that the 
Remove function will accept, but with no luck. 
How should this be done?
0
Olars (1)
1/16/2005 7:29:01 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
570 Views

Similar Articles

[PageSpeed] 8


Urban Olars wrote:
> I'm working in VC++ .Net 2003 with a Unicode project.
> I have a CString object that I want to remove a phrase from that is stored 
> in another CString object. I have looked at the function CString.Remove() but 
> I cannot get this thing to work. It seems to require a datatype called XCHAR, 
> so I have tried to convert my second CString object into something that the 
> Remove function will accept, but with no luck.

Remove is intended for a single character. There is no one operation for 
what you want to do. It will be something like:

int i;
if( (i= str.Find( matchStr )) != -1 )
    str.Delete( i, matchStr.GetLength( ) );

Best, Dan.

-- 
http://lakeweb.net
http://ReserveAnalyst.com
No EXTRA stuff for email.
What can you see if you can't see it all...

0
1/16/2005 8:43:51 PM
Use CString::Find() then create your new CString by using CString::Left() 
and CString::Right()... should be a simple function to write.

    Rail
-- 
      Recording Engineer/Software Developer
      Rail Jon Rogut Software
      http://www.railjonrogut.com
      mailto:rail@railjonrogut.com

"Urban Olars" <Urban Olars@discussions.microsoft.com> wrote in message 
news:B4CB434C-5523-4017-861E-31422A016BFE@microsoft.com...
> I'm working in VC++ .Net 2003 with a Unicode project.
> I have a CString object that I want to remove a phrase from that is stored
> in another CString object. I have looked at the function CString.Remove() 
> but
> I cannot get this thing to work. It seems to require a datatype called 
> XCHAR,
> so I have tried to convert my second CString object into something that 
> the
> Remove function will accept, but with no luck.
> How should this be done? 


0
railro (128)
1/16/2005 10:20:43 PM
>>I have a CString object that I want to remove a phrase from that is stored
>>in another CString object.
I must admit I've not done this with C++ .net but in good old Visual C++ I
used the Replace method with an empty replacement string.

Keith



0
1/17/2005 9:33:33 AM
Reply:

Similar Artilces:

sending CString to CStatic label control from worker thread
I need to send a CString from a thread to a static label on the main dialog form. I think I have the thread working okay, but I am unsure how to send the CString to the dialog control. I have seen information on using PostMessage and SendMessage, but I don't really understand how to use these functions. Obviously I can't do like I tried below and I can't get a pointer to the control from the thread function, so just how do I say send the word "hello" to the SetWindowText() function of the label control on the dialog form. I have looked on the Internet and in se...

Removing Exchange Settings
I had my laptop hooked to an exchange system at work whiol my system was OOC, and now tried to remove the account. Problem is that the account seems to be gone, but at the bottom of OL it still says System Offline like it was still on exchange, and it will not auto send receive any longer (I am assuming because the Exchange account was first). Any ideas on how to fix this? A good start would be to go into Control Panel | Mail, bring up the = properties for your mail profile and tell us what accounts and data = files are included. Your version of Outlook is also relevant=20 --=20 Sue ...

Remove the Formula but leave the value alone?
How easy a macro can be developed to remove the formula but leave the value alone for a group of cells when a special condition matches like my example here? I started with the formula below but realized that I can’t get the result I wanted as to leave the value alone for F4 in the IF formula when the month moving forward. The F4 value originally returned from the Vlookup result. F4: =IF(F2=B1,VLOOKUP($C2,'Sales07'!$B:$Z,10,FALSE),IF(F2>B1,C4+D4+E4,F4)) G4: =IF(G2=B1,VLOOKUP($C2,'Sales07'!$B:$Z,10,FALSE),IF(G2>B1,D4+E4+F4,G4)) H4: =IF(H2=B1,VLOOKUP($C2,'Sale...

Outlook removal
Can anyone tell me how to uninstall Outlook and ALL related files so I may reinstall Outlook and not have it look for previous data files and install all new default files for calendar, contacts, etc. ? ...

CString
How can I covert argv[0] to LPCSTR? Hi, Shouldn't CString(argv[0]) do the trick? Sander Verhagen [ Verhagen@nonono.Sander.com ] "Oliver Young" <please@no.spam.com> wrote in message news:er3JuEogDHA.616@TK2MSFTNGP11.phx.gbl... > > How can I covert argv[0] to LPCSTR? > > > Shouldn't CString(argv[0]) do the trick? OK. And how can I convert CString into LPCSTR? I need LPCSTR. I need to convert from char** ( argv[0] ) into LPCSTR. Please, forget CString, and MFC if possible. > How can I covert argv[0] to LPCSTR? LPCSTR...

CString (again)
I have a class: class TestClass{ public: TestClass(){}; virtual ~TestClass(){}; BOOL CalcArea(double * pArea); void ReversePoints(); void OrderFromLowest(); std::vector<CoordinateClass> Pts; double OrientationType; BOOL XFlip; BOOL YFlip; double LTilt; double RTilt; double Buffer; int Style; CString Name; }; Now when I go like this: TestClass * pNew = new TestClass; pNew->Name = "anything in here will cause an error"; At runtime i get an unhandled exception which is comign from CString::AssignCopy() How do i fix this? Can't seem to reproduce this ...

Remove songs from portable player
I want to remove songs from a portable player without totaly screwing up the sync relationship or having them deleted from the computer. Running WMP11 on XP SP3. Having no problems like what i have read in here, I just want to remove some songs. Previously had to copy entire library to another folder because the library would get deleted along with what is on the portable unit, and then restore to My Music. If I use Explorer to go into the players drive and delete the files then WMP still thinks that they are in there and wont re-sync, wont delete unless you delete files from lib...

std::string vs Cstring
Hello, I have recently been encouraged to utilise String classes, as opposed to C type char arrays due to some difficulty debugging some buffer overflows. I have looked into std::string and CString, but what are the benefits and drawbacks? The main problem I have is that I do a lot of data formatting using sprintf, for which I see no substitute using std::string, - MR On Thu, 30 Dec 2004 23:25:21 -0000, "Mark Randall" <strike@rapiercom.freeserve.co.uk> wrote: >Hello, > >I have recently been encouraged to utilise String classes, as opposed to C >type cha...

Removing Item from Spending Tracker
I am using MS Money 2006 and have many items on my spending tracker which shows on the startup page. I have one called "Auto Loan" which I just paid in full and would like to remove it from the spending tracker shown on the startup page. If you click on the "Change areas you watch closely" at the bottom of the spending tracker, this "Auto Loan" is not listed in the selection area. Is there another way to remove and add items I watch besides the "Change items" hyperlink at the bottom of this page? I can not seem to find another place to add/remove ...

OE attachment Removed
Whenever I receive an attachment that is not a *.doc Outlook Express puts up a message saying "OE has removed the attachment, then the name" I assume this is a security setting but can't figure out where to change it. Open Outlook Express and select Tools | Options | Security tab. Uncheck the second box from the top. "Howard" <Howard.Bentley@wachovia.com> wrote in message news:06a501c36579$d6688c90$a601280a@phx.gbl... > Whenever I receive an attachment that is not a *.doc > Outlook Express puts up a message saying "OE has removed > the atta...

Cannot remove Outlook 2000
This problem has been an occasional thorn in my side, but has become a big problem since installing Office XP. The computer in question has been through Office 97 with Outlook 98, Office 97 with Outlook 2000 and now Office XP with Outlook 2002. The problem is that even after I install Office XP, Outlook 2000 is still listed in Add/Remove programs and appears to still be there in some form. When I open several other programs the Outlook 2000 SR-1 setup starts and it tries to install something (I don't know what) and even if you follow the instructions to install whatever it's looking ...

How to covert CString to TCHAR and CString to LPCWSTR?
How to covert CString to TCHAR and CString to LPCWSTR? Where can I read about this? See my essay on CStrings on my MVP Tips site. joe On Mon, 30 Jun 2003 04:33:56 -0700, "julych" <julych@msn.com> wrote: >How to covert CString to TCHAR and CString to LPCWSTR? >Where can I read about this? Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm ...

remove carriage return in multiple cells
Hello, I have an excel sheet with lots of data. Unfortunately lots of cells contain carriage returns. Is there a way to remove the carriage returns in those cells (more returns in a cell possible)? Thanks, Andy > Andy Select your range, then CTRL+H. In Find What, type 0010 (number keypad) while holding down ALT. Click Replace All. HTH, Andy Try running this macro: Sub RemoveCRLF() Cells.Replace Chr(10), "" Cells.Replace Chr(13), "" End Sub Afterward you may want to turn off Wrap Text (under Format, Cells, Alignment) for the affected cells. -- Jim...

How to add/remove printers using group policy
I'm the Accidental IT admin for my church. The previous admin used Group Policy to add the wrong printer to all our PCs. The staff would like it removed permanently (it comes back every time they log on). I'm very unfamiliar with the group policy editor. Can any of you give me any tips on how to do this using gpedit? Our system consists of an SBS 2008 server, a Win 2008 server (running SQL), and a mix of Win XP Pro, Vista Pro and Win 7 Pro clients. Things that (I think) that I specifically need to know include: - "gpedit" is the correct command to run? - W...

CString...
What is the maximum characters a CString variable can hold? Is there anyway to increase a CString variables capacity to hold more characters? Thanks, RABMissouri As all index and length parameters are int variables, and there is no checking on assignment, the limit would be 2147483647 on a 32bit machine. If that's not big enough, rethink what you're doing. Jase "RBert" <drbert@microcore.net> wrote in message news:OB24du6FEHA.2308@tk2msftngp13.phx.gbl... > What is the maximum characters a CString variable can hold? Is there anyway > to increase a CString va...

To Remove Kodak
Is there any program, like msicuu2, that will completely clean Kodak out of my PC? bandi wrote: > Is there any program, like msicuu2, that will completely clean Kodak out of > my PC? > > uninstall it through it's uninstaller or else through the control panel Something wrong with using Add/Remove Programs? bandi wrote: > Is there any program, like msicuu2, that will completely clean Kodak out > of > my PC? And if it's not listed in there, Revo Uninstaller may find it, but be careful with that one! PA Bear [MS MVP] wrote: >...

How to convert a BSTR to CString ??
I'm sure I'm missing something easy but..... How does one convert a BSTR to a CString? More specifically, I am processing the returned VARIANT value from an ActiveX control and it's value is a BSTR that I would like to move to a CString. Thanks in advance for your help. Bob Curry BSTR bstrValue; CString szValue; szValue = (LPCWSTR)bstrValue; Sreeram. Bob Curry wrote: > I'm sure I'm missing something easy but..... How does one convert a BSTR > to a CString? More specifically, I am processing the returned VARIANT value > from an ActiveX control and it...

CString in DLL
When I try to use CString in an MFC DLL, it gives the following error: error LNK2019: unresolved external symbol "public: __thiscall CString::~CString(void)" (??1CString@@QAE@XZ) referenced in function "public: virtual int __thiscall CMfcDllApp::InitInstance(void)" (?InitInstance@CMfcDllApp@@UAEHXZ) How can I use CString? Forgot to mention that the Env used is VC++ .NET "ajd" <ajaydhar@hotmail.com> wrote in message news:eLGoiPFMEHA.2388@TK2MSFTNGP09.phx.gbl... > When I try to use CString in an MFC DLL, it gives the following error: > > error L...

toggling removable bit for A Data SDHC? (so XP sees SDHC as a Fixed Drive)
I want to convert my A Data brand 16 GB SDHC (Class 6) to type "fixed" instead of "removable" so I can install & run XP on the SDHC card, or extend the Mini's C:\ drive partition to the card as described here: How to extend system partition (extend c drive) to optimize the performance of your computer? http://www.partition-tool.com/easeus-partition-manager/extend-system-partition.htm Does anyone know where to find the utility or any instructions on how to toggle the Removable Media Bit (RMB) for this particular (A Data) SDHC card, so Windows an...

Array of CString s vs. CString Array
Hi all What's the deal with CStringArray? I have used CStringArray in several places but now I'm wondering why can't I use an array of CStrings instead - at least I wouldn't have to bother with SetSize(). TIA Richard C You can use whatever you like. CStringArray has been part of MFC before vector other STL collection became a part of C++. I'd use vector<CString>. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Richard C" <rc@replytogroup.com> wrote in message news:tN97h.67412$rP1.57615@news-server.bigpond.net.au... > Hi all > > What&...

Out to remove entries from the quick fill list..
Outlookers, When you create a new email message in Outlook and type a character in the "To:" field, Outlook immediately pops up with a quick list of all the names that match the character. In my case, I have one person with two email addresses: bob (bob@xyc.com) bob (bob@abc.com) I am used to just typing "bob" and sending the email out. As a result, the email ends up going to Bob's home (the first email address) and that is not desirable. How do I get rid of the first entry altogether? This entry is definitely not in my address book. It appears each time an emai...

removing delegates name from Sent On Behalf Of within outlook,
Hi can anyone tell me how to remove the delgates name when sending a mail on behalf of a generic email account ? . I would really appreciate the advise as having the delegates name displayed causes conflict in the work place You cannot do this with "Send On Behalf Of" permissions. The Exchange admin will have to set "Send As" permissions for those users on the AD object that holds the mailbox. -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http...

Are there any function like ReplaceNoCase for CString?
I can only find CString::Replace, but I need a function like ReplaceNoCase You are correct. Replace is case sensitive. You could convert the string to all upper or lower case first, but then your resulting string would be changed as well. You could also derive your own class from CString and add the new functionality to it. Tom <flyingxu@gmail.com> wrote in message news:1145000483.010766.64070@t31g2000cwb.googlegroups.com... >I can only find CString::Replace, but I need a function like > ReplaceNoCase > ...

Issue with casting CString to LPARAM and recasting it to CString...
Hi, I have developed a custom control with some customizations of the List Control class of MFC (CListCtrl). I have another custom class (MyItem) which is inherited from CItem. Each and every entry in the list control is a MyItem. Every time a new item is added into the LIst control we use the logic of maintaining a unique sequence number which is a CString and member of MyItem class. Here goes the implementation of the 2 main members of MyItem class void MyItem::SetListItemSequence(const CString& seq) { m_sequence = seq; } This member sets the newly added entries sequence value into ...

Removing a character in a field
Hi, I have a table which contains an asterisk marks in some of the fields in some records. What would be the easiest way to get rid of them? Wherever there are asterisk, I need them to be Null fields. I tried with Find and replace with "" mark, but it doesnt seem to work. Am I missign something? Thanks Ramesh On Wed, 20 Jun 2007 07:46:59 +0530, "Ramesh" <ramesh2020@gmaildotcom> wrote: >Hi, > >I have a table which contains an asterisk marks in some of the fields in >some records. What would be the easiest way to get rid of them? Wherever >th...