Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. very confusing formatting symbols

very confusing formatting symbols

Scheduled Pinned Locked Moved C#
helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pyro Joe
    wrote on last edited by
    #1

    ok, I have a variable, of which I need to escape its contents. the problem is, I don't want to escape out the variable, but I do want to escape out its contents as I said earlier. also, the reason I have to escape the variable, is because it will have potentially these symbols: ",;@' . this is a problem, because it will mess up the symbols used in my code to ignore the variable's string value (containing those symbols.) how do I do this? I don't want to use the escape way, because that doesn't work. any ideas? I'm totally stuck. also, how do I insert the ' symbol into a textbox? thanks for the help, Stephen

    S L 2 Replies Last reply
    0
    • P Pyro Joe

      ok, I have a variable, of which I need to escape its contents. the problem is, I don't want to escape out the variable, but I do want to escape out its contents as I said earlier. also, the reason I have to escape the variable, is because it will have potentially these symbols: ",;@' . this is a problem, because it will mess up the symbols used in my code to ignore the variable's string value (containing those symbols.) how do I do this? I don't want to use the escape way, because that doesn't work. any ideas? I'm totally stuck. also, how do I insert the ' symbol into a textbox? thanks for the help, Stephen

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      I can't really understand your question? Can you give a short sample program that demonstrates it? And doesn't textbox.Text += "'" work? Regards Senthil My Blog

      P 1 Reply Last reply
      0
      • S S Senthil Kumar

        I can't really understand your question? Can you give a short sample program that demonstrates it? And doesn't textbox.Text += "'" work? Regards Senthil My Blog

        P Offline
        P Offline
        Pyro Joe
        wrote on last edited by
        #3

        oops, yeah, "'" works. I meant how to insert the " symbol. int current = 1; int lines = richTextBox1.Lines.GetLength(0); if (lines < 3) { MessageBox.Show("You need to have atleast three lines, otherwise this application is useless", "Useless he he ;)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { richTextBox2.Text = '"' + richTextBox1.Lines[0] + '"' + " " + '+' + " " + '"' + @"\r\n" + '"' + " " + '+' + " "; while (lines > 2) { richTextBox2.Text += '"' + richTextBox1.Lines[current] + '"' + " " + '+' + " " + '"' + @"\r\n" + '"' + " " + '+' + " "; current ++; lines --; } if (lines > 1) { richTextBox2.Text += '"' + richTextBox1.Lines[current] + '"'; } } what happens is, the user inputs text into the richTextBox1, and when the user clicks a button to run the above code, the code is sent to the richTextBox2. the problem is, all the code must be on one line, formatted properly on that line, and display the formatting (text) necessary for the outputted code to be useable in another application where there could potentiall be hundreds of lines of text, without manuall writing all the "\r\n"'s to format it. the problem is, what if the person puts in "\r\n" into the input richTextBox1? or what if they put in a " symbol or a ; symbol. the contents of richTextBox1 are formatted in the code above, but the problem is, where you see "richTextBox1.Lines[current]", the symbols that user inputted as described above, screw up the formatting when ouputting the text to richTextBox2. like for instance, say I put the " symbol in richTextBox2. it will then think it has reached the end of the string to be formatted, when that is not the correct " symbol to stop at. please help, this would be a very helpful application to people I think, atleast for me when I want to format many paragraphs so I can just paste the code for an application that needs text formatted to a textbox in such a way. the current code I have works like a dream, except it messes up as described above when these symbols are inserted: ; ' " + and possibly a couple others. if there is no easy way you can think of, my idea was to use a regular expression, and select and replace all those symbols with "'", etc. the problem with this is, """ doesn't work to place the " symbol to a string or insert it into a text box as text. same with the ; and other symbols. how do I do this? hilf mir!!!, Danke schoen, Stephen

        1 Reply Last reply
        0
        • P Pyro Joe

          ok, I have a variable, of which I need to escape its contents. the problem is, I don't want to escape out the variable, but I do want to escape out its contents as I said earlier. also, the reason I have to escape the variable, is because it will have potentially these symbols: ",;@' . this is a problem, because it will mess up the symbols used in my code to ignore the variable's string value (containing those symbols.) how do I do this? I don't want to use the escape way, because that doesn't work. any ideas? I'm totally stuck. also, how do I insert the ' symbol into a textbox? thanks for the help, Stephen

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Pyro Joe wrote: I don't want to use the escape way, because that doesn't work. It does, just read the docs. xacc-ide 0.0.12 now with C#, MSIL, C, XML, ASP.NET and HLSL coloring - Screenshots

          P 1 Reply Last reply
          0
          • L leppie

            Pyro Joe wrote: I don't want to use the escape way, because that doesn't work. It does, just read the docs. xacc-ide 0.0.12 now with C#, MSIL, C, XML, ASP.NET and HLSL coloring - Screenshots

            P Offline
            P Offline
            Pyro Joe
            wrote on last edited by
            #5

            see the problem is, that I need to escape the contents of the variable, not the variable itself. so escaping it would place the variable into the text, rather than its contents. also, as earlier, the " symbol would stop the escape before the correct " symbol is reached. this would mess things all up.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups