Change colour of SOME text in a Label

02-21-2005, 10:31 AM
Is it possible to change colour of SOME text in a label. I have a rolling label at the bottom of my app. And it shows a netadress sometimes.. it whould be nice if this whould appear in blue..
Eks: "Hi, welcome to my app. Visit: to learn more :)"

Something like that

02-21-2005, 11:47 AM
Have you tried maybe 3 labels. A label with black text caption, then a label with blue text caption, and then another label with black caption text, all place appropriately next to each other and all with:

BackStyle = 0 'Transparent

...then you could even use a label with regular grey background and no caption text that sits behind all three of these just to make everything look like nice (like it's part of one label). It might be a little more work to shift things around on the fly to get the scrolling to work right, but play around and I'm sure you can get it working with multiple labels...

02-21-2005, 07:38 PM

Simply write colored text to a picturebox or a zone on the form itself.
The following sample will print in colors on a single line in a picturebox.

Option Explicit

Private Sub Command1_Click()
Dim sTextLn As String

sTextLn = "Good Morning! | |Read em and weep."

WriteAt Picture1, 100, 100, sTextLn, vbBlack, vbBlue, vbRed
End Sub

Private Sub WriteAt(ByVal P1 As PictureBox, _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal sText As String, _
ParamArray Color())

Dim s() As String
Dim i As Integer

s = Split(sText, "|")

For i = 0 To UBound(s)
P1.CurrentX = x
P1.CurrentY = y
P1.ForeColor = Color(i)

P1.Print s(i)
x = x + TextWidth(s(i))
Next i

End Sub

Have Fun,


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum