C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-24-2009, 05:49 AM   #1
Registered User
 
Join Date: Jan 2008
Posts: 225
A small problem spoiling my application!

Hello,

The problem is quiet trivial. Say suppose i have "Hello friendes{BACK}{BACK}s" in one file. Now when i print the file's contents in textbox it should print "Hello friends"
({BACK} = backspace key). I don't know how to do this. I tried

Code:
stringvariable.Replace("{BACK}","\b");
but it's not working. I even tried this for loop

Code:
  while(1 > 0)
  {
      int intIndex = StringToFormat.IndexOf("{BACK}");
      if (intIndex <= -1)
          break;
      if (intIndex == 0)
          StringToFormat = StringToFormat.Remove(0, 6);
      else
          StringToFormat = StringToFormat.Remove(intIndex - 1, 7);
  }
because the user may press several backspaces simultaneously. Please help me!
Thanks in advance
chottachatri is offline   Reply With Quote
Old 07-24-2009, 04:06 PM   #2
int x = *((int *) NULL);
 
Cactus_Hugger's Avatar
 
Join Date: Jul 2003
Location: Banks of the River Styx
Posts: 902
I don't believe that a \b makes any sense outside of the context of a terminal nowadays. A textbox will probably just draw one of those cute little boxes at you.

The second method looked valid though... step through it with the debugger.

(And... you ARE setting the value of the text box somewhere... right? Assuming it's a System.Windows.Forms.TextBox, the .Text property, IIRC.)
__________________
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
Cactus_Hugger is offline   Reply With Quote
Old 07-24-2009, 10:34 PM   #3
Registered User
 
Join Date: Jan 2008
Posts: 225
Thanks Cactus_Hugger you are right it draws a funny little box. And ya, the while loop is absolutely correct actually the problem was somewhere else. I corrected it! Thanks anyways!

Though when i use

Code:
stringvariable.Replace("{ENTER}","\r\n");
it works
So i thought may be "\b" would also work
chottachatri is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
a very small problem, i'm new... please help? Uberverse C++ Programming 9 11-10-2007 10:44 AM
A question related to strcmp meili100 C++ Programming 6 07-07-2007 02:51 PM
Problem w/ console application compadibility DarkMortar C Programming 2 05-16-2006 07:13 PM
Small program big problem :-( Fibre Optic C++ Programming 4 09-20-2005 08:53 AM
Need Big Solution For Small Problem GrNxxDaY C++ Programming 8 08-01-2002 03:23 AM


All times are GMT -6. The time now is 11:31 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22