Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change colour of just part of a label 1

Status
Not open for further replies.

jeffwest2

MIS
Feb 5, 2009
64
GB
Trying to change a label so that it colours a '*' red to mark it as mandatory so it reads as Month *

I have tried web searches and I can seem to colour the whole text or the border red but not just a small bit of it.

Any help would be great.

Didn't anyone ever tell you? There's one thing you never put in a trap — if you're smart, if you value your continued existence, if you have any plans about seeing tomorrow — there's one thing you never — ever, put in a trap. … Me.
 
This cannot be done with a plain label. You can use a textbox formatted as a label set to "rich text", and make it look like a label. A rich textbox allows this.
 
To understand how this works you can run this demo.

Create a textbox and format it to look like a label. Lock it. Call it
"txtBxLabelOne"

Code:
Private Sub Form_Load()
  loadLabels
End Sub

Public Sub loadLabels()
   Dim lblCaption As String
   lblCaption = "<div><font color=#ED1C24>Red </font><strong>Bold</strong> <em>Italic</em> <u>Underline</u></div>"
   Me.txtBxLabelOne.Value = lblCaption
End Sub

You will see a "label" that is part red, bold, italic, and underline
 
MajP, thanks this worked and is exactly what I needed.

Didn't anyone ever tell you? There's one thing you never put in a trap — if you're smart, if you value your continued existence, if you have any plans about seeing tomorrow — there's one thing you never — ever, put in a trap. … Me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top