Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 13th, 2003, 06:40 AM
James7285 James7285 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 James7285 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Highlited Text Help

Right this is what I need to do...

Say u have a text box on a form and a command button.

When U click the command button the text colour would turn Red...

So the code would be

text1.forecolor = vbRed

Is there anyway you can make so you can highlight some text in the text box and when u click the button ONLY the highlighted text would turn Red and the rest of the text in the box would Stay black?

Thanks in adavcne

James

Reply With Quote
  #2  
Old July 13th, 2003, 10:16 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Do you only want to highlight only a portion of the text in a text box?

Reply With Quote
  #3  
Old July 22nd, 2003, 04:56 PM
lmck lmck is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 4 lmck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I don't know of an easy way to do it with a textbox. You can do it using a Rich text Box (Project->Components->Microsoft Rich Textbox Control). Then you can use:

Private Sub ChangeColor_Click()

txtRichTextBox.SelColor = vbRed 'set selected text color

End Sub

Of course, you can also select the text to change in your code

Private Sub ChangeColor2_Click()

'Turns 1st 10 characters red

txtRichTextBox.SelStart = 0 'start of selection
txtRichTextBox.SelLength = 10 'lenght of selection
txtRichTextBox.SelColor = vbRed 'set selected text color
txtRichTextBox.SelLength = 0 'remove the selection highlight

End Sub

Using the Rich Textbox you can also change the font, alignment etc of portions of text. The drawbacks are that the RTB uses more resources and you have to distribute an extra file (the ocx) if you install the program somewhere else. These may not be a problem, depending on your needs.

Last edited by lmck : July 22nd, 2003 at 05:01 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Highlited Text Help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway