I want to make a list box and select an index to HighLight a specific part or whole Text or Label, But I don't know how to code for HighLight. Please help me!
:( :confused: :check:
Printable View
I want to make a list box and select an index to HighLight a specific part or whole Text or Label, But I don't know how to code for HighLight. Please help me!
:( :confused: :check:
To highlight a piece of text in a TextBox use the .SelStart and .SelLenght properties
You can't highlight pieces of a text in a Label control
Many Thanks Dear #Arnoutdy !
You can highlight whole or part of any text in a label
:) I found something easy
---------------
If List1.ListIndex = 0 Then
With Label1
.Visible = True
.Width = 3000
.Height = 1500
.Left = 2100
.Top = 60
End With
Label2.Visible = False
ElseIf List1.ListIndex = 1 Then
With Label2
.Visible = True
.Width = 3000
.Height = 1500
.Left = 2100
.Top = 60
End With
Label1.Visible = False
End If
End Sub
------------------
Private Sub List1_Click()
On Error Resume Next
If List1.ListIndex = 0 Then
With Label1
.Visible = True
.Width = 3000
.Height = 1500
.Left = 2100
.Top = 60
End With
Text1.Text = "Bleeding time is a laboratory test to assess platelet function and the body’s ability to form a clot. The test involves making a puncture wound in a superficial area of the skin and monitoring "
Text1.SetFocus
Text1.SelStart = 14
Text1.SelLength = Len(Text1.Text) - 122
Label2.Visible = False
ElseIf List1.ListIndex = 1 Then
With Label2
.Visible = True
.Width = 3000
.Height = 1500
.Left = 2100
.Top = 60
End With
Text1.Text = "Bleeding time is a laboratory test to assess platelet function and the body’s ability to form a clot. The test involves making a puncture wound in a superficial area of the skin and monitoring "
Text1.SetFocus
Text1.SelStart = 85
Text1.SelLength = Len(Text1.Text) - 118
Label1.Visible = False
End If
End Sub
So, MKP, how does your code highlight part of the caption (you called it text) of a label. Your code does nothing except sets basic stuff for your labels, but does nothing with their captions.
Still waiting on "On Error Try Again"'s answer to my question in post #6.
when you click (listIndex=0) text1 will foucs a part of text not all of text and highlights that part, and when you click (listIndex=1) it will select and highlight another part.
BUT NOT LABELS! At least YOUR code doesn't highlight a portion of the text (.caption) of your labels.
So, never mind, guess I have no idea what you are trying to do with labels anyway...adios.
Yes, I tried to highlight a part of label, but i couldn't do it. :(