|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
Do you only want to highlight only a portion of the text in a text box?
|
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Highlited Text Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|