Text Help: How do you add a " in a text output?
-
miércoles, 15 de agosto de 2012 7:07
I'm making a simple HTML editor and I need it to allow me to add " in it with out closing the section.
This is HTMl of course but Im trying to make this type it in for you and Im using VB of course to auto add this line of code for you.
rtbHTMLCode.AppendText("<FONT FACE="Arial" SIZE="FontSize")
Of course the problem is the " in it causes it to close. Suggestions or work arounds?
Todas las respuestas
-
miércoles, 15 de agosto de 2012 7:53
Four quotes in a row represents a single quote in this fashion. The output to the TextBox is a single quote.
TextBox1.Text = """"
You've taught me everything I know but not everything you know.
- Marcado como respuesta old_School miércoles, 15 de agosto de 2012 7:57
-
miércoles, 15 de agosto de 2012 7:58Thank you I hope it works
-
miércoles, 15 de agosto de 2012 9:41
Thank you I hope it works
Probably not. Please see:
http://msdn.microsoft.com/en-us/library/267k4fw5.aspx
How to: Put Quotation Marks in a String (Windows Forms)- Marcado como respuesta old_School miércoles, 15 de agosto de 2012 15:06
-
miércoles, 15 de agosto de 2012 15:06Ahh nice save Acamar
-
miércoles, 15 de agosto de 2012 15:26
rtbHTMLCode.AppendText("<FONT FACE=" & Chr(34) & "Arial" & Chr(34) & " SIZE=" & Chr(34) & "FontSize" & Chr(34) & ")"
I've always used that rather than the multiple quote marks. To me it's more obvious if/when something isn't working right, but it's personal preference really. If you have a lot of these to do though, I'd suggest a different approach (I've done this several times):
Create some text-only "template" files. For instance in that one, you'd have the entire line (HTML) and substitute keywords that you can then later replace in your program. For example in that one, that line might look like this in a text file:
<FONT FACE="*FONT_NAME_HERE*" SIZE="*FONT_SIZE_HERE*")
In your program, look for *FONT_NAME_HERE* and have your program replace that with the name of the font. Do the same for font size, obviously.
Because strings are immutable though, consider using a StringBuilder and the StringBuilder's ".Replace" method.
For what it's worth :)
Please call me Frank :)
-
miércoles, 15 de agosto de 2012 15:36
I going to use & Chr(34) method I preffer ASCII method when I can use it. Numbers are just easier to work with I think.
rtbHTMLCode.AppendText(
"<FONT COLOR=" & Chr(34) & FontColor & Chr(34) & "FACE=" & Chr(34) & "Arial" & Chr(34) & " SIZE=" & Chr(34) & FontSize & Chr(34))
- Editado old_School miércoles, 15 de agosto de 2012 15:39
-
miércoles, 15 de agosto de 2012 15:40
I going to use & Chr(34) method I preffer ASCII method when I can use it. Numbers are just easier to work with I think.
rtbHTMLCode.AppendText(
"<FONT COLOR=" & Chr(34) & FontColor & Chr(34) & "FACE=" & Chr(34) & "Arial" & Chr(34) & " SIZE=" & Chr(34) & FontSize & Chr(34))
Don't forget the closing HTM tag on the end there.

Please call me Frank :)

