A small problem spoiling my application!

This is a discussion on A small problem spoiling my application! within the C# Programming forums, part of the General Programming Boards category; Hello, The problem is quiet trivial. Say suppose i have "Hello friendes{BACK}{BACK}s" in one file. Now when i print the ...

  1. #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

  2. #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)

  3. #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

Popular pages Recent additions subscribe to a feed

Similar Threads

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

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