Getox Posted September 15, 2005 Posted September 15, 2005 OK, I have a Rich Textbox now if i had say this code in it: <html> <head> <title></title> </head> <body> </body> </html> Now, i have a button that will add: <style> </style> But that goes at the bottom of the page, How would i get it to add this before the </head> tag? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Administrators PlausiblyDamp Posted September 15, 2005 Administrators Posted September 15, 2005 What code are you using to add this? If you are implementing a text editor then you will probably find the TextBox / RichTextBox controls will start to get a bit cumbersome as a way to do both store and edit the text. You may want to look at some alternate storage ideas (arrays, lists etc) and only use the controls to display / edit the string. Clicky is probably worth a read as it does give some good explanations of various possible approaches. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Getox Posted September 15, 2005 Author Posted September 15, 2005 Well, i aint coded that part yet, but if i was to code it, i would just do a codebox.appendtext = "<style> </style>" ....Anyone know how to do a multiline one? as codebox.appendtext = "this wont work" Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Machaira Posted September 15, 2005 Posted September 15, 2005 If you want to put the text before the "</head>" tag why would you be looking for an append function? Just because I'm a nice guy I'll give you this one :) ;) : Dim sText As String = "<style>" & Environment.NewLine & Environment.NewLine & "</style>" RichTextBox1.Text = RichTextBox1.Text.Insert(RichTextBox1.Text.IndexOf("</head>"), sText) Quote Here's what I'm up to.
Getox Posted September 15, 2005 Author Posted September 15, 2005 Thanks heaps for that, Works great. Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Getox Posted September 16, 2005 Author Posted September 16, 2005 Ok, i got a problem, if the text "</head>" isnt in the textbox it crashes the app, how would i stop it from doing that? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Machaira Posted September 16, 2005 Posted September 16, 2005 Move the part: RichTextBox1.Text.IndexOf("</head>") before the insert, storing the return value in a variable. Check the variable - if it's -1 don't do the insert. Quote Here's what I'm up to.
Getox Posted September 17, 2005 Author Posted September 17, 2005 Move the part: RichTextBox1.Text.IndexOf("</head>") before the insert, storing the return value in a variable. Check the variable - if it's -1 don't do the insert. Little help with that please, What exacly do i do? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Machaira Posted September 19, 2005 Posted September 19, 2005 The IndexOf function returns a number which tells you the location of the string passed to the function in the text that's searched, in this case the text in the RichTextBox. If that number is -1 the string isn't in the text so you don't want to do the insert. Surely you can modify the code on your own. If you want someone to do your coding for you, try http://www.rentacoder.com. ;) Quote Here's what I'm up to.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.