Change color in middle line of userform label

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
174
I have a userform label caption with 3 lines. How to change the color of the middle line? I would like the top and bottom lines red and the middle line black.
The middle line is from a textbox entry.
I know I could simply divide the the caption into 3 different labels but I would like a more elegant solution.

VBA Code:
With calinc.Label1
        .Caption = "Calibrant Input" _
                    & vbNewLine & _
                    """" & caltex.stanbox & """" _
                    & vbNewLine & _
                    "Incorrect. Re-Enter"

Thanks for any help.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
It doesn't look it's possible, but here's a possible alternative that uses the InkEdit control...


Otherwise, you can always cheat and use 3 separate labels to do what you want. :)

Cheers!
 
Upvote 0
Thanks Domenic. I used 3 labels. Just a few extra lines.


VBA Code:
Sub show_moninc()
moninc.Show vbModeless
With moninc
    .Top = 300
    .Left = 300
    .Height = 150
    .Width = 250
    .Caption = "show_moninc"
    With moninc.Label1
        .Caption = "Monitor Input"
        .Top = 0
        .Width = moninc.Width
        .Height = 30
        .Left = (moninc.InsideWidth - .Width) / 2
        With .Font
                .Size = 20
                .Bold = True
                .Name = "Arial"
        End With
        .ForeColor = vbRed
        .TextAlign = fmTextAlignCenter
    End With
    With moninc.Label2
        .Caption = """" & montex.stanbox & """"
        .Top = 24
        .Width = moninc.Width
        .Height = 30
        .Left = (moninc.InsideWidth - .Width) / 2
        With .Font
                .Size = 20
                .Bold = True
                .Name = "Arial"
        End With
        .ForeColor = vbBlack
        .TextAlign = fmTextAlignCenter
    End With
    With moninc.Label3
        .Caption = "Incorrect. Re-Enter"
        .Top = 48
        .Width = moninc.Width
        .Height = 30
        .Left = (moninc.InsideWidth - .Width) / 2
        With .Font
                .Size = 20
                .Bold = True
                .Name = "Arial"
        End With
        .ForeColor = vbRed
        .TextAlign = fmTextAlignCenter
    End With
    With moninc.moninc_but
        .Caption = "OK"
        .Top = 80
        With .Font
                .Size = 14
                .Bold = True
                .Name = "Arial"
        End With
        .ForeColor = 0
        .AutoSize = True
        .Left = (moninc.InsideWidth - .Width) / 2
    End With
End With
Do While moninc.Visible
DoEvents
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top