Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996

Providing Multiple Colors

Question:
I having trouble using strings and text. I am writing a document creation system and all the text in between the "<" char. and the ">" char. would be red. All other text would be red.

Answer:
The first problem is getting multiple colors in a text box. You'll have to use a different control from the standard text box, since it doesn't support multiple colors. Take a look at my File Archives area for a selection of enhanced text boxes. If you're using VB4.0 you can use the RichTextBox control. You'd want to use the Instr Function to check each new line of text, if you find a "<" character you'd remember the position (Instr returns that as an Integer) and then start a fresh Instr from there to find the ">" character. Now you know where your string to change color lies... you'd then use the SelStart and SelLength the select that string and set its color property (I believe it's the Foreground property) to red (or whichever color you like).

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date