Hi all,
As i'm new to VB 6.0, anyone could help me to find out this issue?
how to change the color of text which is in textbox?
thanks in advance
:cool:
Hi all,
As i'm new to VB 6.0, anyone could help me to find out this issue?
how to change the color of text which is in textbox?
thanks in advance
:cool:
Echoing : the textbox’s ForeColor property is what controls the text color and can be set at design time or changed at run time. ForeColor accepts OLE color values (you can supply an RGB value or use VB color/system-color values), so both programmatic assignment and the Properties window work. (learn.microsoft.com)
If you want a quick runtime example, use a VB color constant or let the user pick a color with the Common Dialog (as hinted). For example:
' set a standard VB color
Text1.ForeColor = vbBlue
' let the user choose a color (CommonDialog control)
CommonDialog1.ShowColor
Text1.ForeColor = CommonDialog1.Color The Common Dialog returns a color you can assign directly. (livrozilla.com)
A practical tip: do not use Enabled = False if you want to keep your chosen ForeColor visible — disabling a control makes Windows render it with disabled/system colors. Use TextBox.Locked = True (or make it read-only via the control API) to prevent editing while preserving the visual color and the ability to select/copy text. (xxxmen.github.io)
If the goal is to color only part of the text (not the whole TextBox), the standard TextBox cannot do that. Use the RichTextBox ActiveX instead: select the substring (SelStart/SelLength) and set SelColor for just that range. You must add the RichTextBox control (Project → Components) before using it. (stackoverflow.com)
Notes: for advanced highlighting you can also manipulate the control’s RTF; and when mixing system vs custom colors be aware OLE_COLOR values can encode RGB or system color indices. (learn.microsoft.com)
Jump to Post— selvaganapathy 31Hi, In property window
> Change the ForeColor property of the Text box.
Or by code
Text1.ForeColor = RGB (255, 255, 0)
Hi, In property window
> Change the ForeColor property of the Text box.
Or by code Text1.ForeColor = RGB (255, 255, 0)
Hee hee
I got it
:D :P
you can also change that ar eruntime by using color dialogbox of commondialog control.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.