msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

bold text in label

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
spitapps



Joined: 04 Oct 2007
Posts: 3

PostPosted: Mon Oct 09, 2006 4:48 pm    Post subject: bold text in label Reply with quote

I am putting text in a label as a variable. But i want just the
variable text to be bold face, so like:

The variable is value of the variable blah blah.

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Bob Butler



Joined: 04 Oct 2007
Posts: 1325

PostPosted: Mon Oct 09, 2006 4:53 pm    Post subject: Re: bold text in label Reply with quote

"spitapps" wrote in message@m7g2000cwm.googlegroups.com
> I am putting text in a label as a variable. But i want just the
> variable text to be bold face, so like:
>
> The variable is value of the variable blah blah.

Label1.FontBold = True
-or-
Label1.Font.Bold = True

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Back to top
View user's profile Send private message
spitapps



Joined: 04 Oct 2007
Posts: 3

PostPosted: Mon Oct 09, 2006 5:13 pm    Post subject: Re: bold text in label Reply with quote

Bob Butler wrote:
> "spitapps" wrote in message
> @m7g2000cwm.googlegroups.com
> > I am putting text in a label as a variable. But i want just the
> > variable text to be bold face, so like:
> >
> > The variable is value of the variable blah blah.
>
> Label1.FontBold = True
> -or-
> Label1.Font.Bold = True
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."

No i mean like i want half of the text to be bold and the other half
not bold.
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Mon Oct 09, 2006 5:18 pm    Post subject: Re: bold text in label Reply with quote

spitapps wrote:
> Bob Butler wrote:
>>> I am putting text in a label as a variable. But i want just the
>>> variable text to be bold face, so like:
>>>
>>> The variable is value of the variable blah blah.
>>
>> Label1.FontBold = True
>> -or-
>> Label1.Font.Bold = True
>
> No i mean like i want half of the text to be bold and the other half
> not bold.

Then you'll need to roll yer own UserControl. That's not supported in the
standard Label control.
--
Working without a .NET?
http://classicvb.org/
Back to top
View user's profile Send private message
spitapps



Joined: 04 Oct 2007
Posts: 3

PostPosted: Mon Oct 09, 2006 5:34 pm    Post subject: Re: bold text in label Reply with quote

Bob Butler wrote:
> "spitapps" wrote in message
> @m7g2000cwm.googlegroups.com
> > I am putting text in a label as a variable. But i want just the
> > variable text to be bold face, so like:
> >
> > The variable is value of the variable blah blah.
>
> Label1.FontBold = True
> -or-
> Label1.Font.Bold = True
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."

No i mean like i want half of the text to be bold and the other half
not bold.
Back to top
View user's profile Send private message
"Rick Rothstein \



Joined: 04 Oct 2007
Posts: 1584

PostPosted: Mon Oct 09, 2006 8:42 pm    Post subject: Re: bold text in label Reply with quote

>> > I am putting text in a label as a variable. But i want just the
>> > variable text to be bold face, so like:
>> >
>> > The variable is value of the variable blah blah.
>>
>> Label1.FontBold = True
>> -or-
>> Label1.Font.Bold = True
>>
>> --
>> Reply to the group so all can participate
>> VB.Net: "Fool me once..."
>
> No i mean like i want half of the text to be bold and the other half
> not bold.

You can't... a Label doesn't support that functionality. You might consider
using a TextBox with the Locked property set to True.

Text1.Text = "The variable is XXX blah blah."
Text1.SelStart = InStr(Text1.Text, "XXX")
Text1.SelLength = 3
Text1.SelText = StringVariable
Text1.SelBold = True.

At this point, you can either do this

Text1.SelStart = Len(Text1.Text)

to get rid of the selection and place the caret at the end of the text. Or,
you can SetFocus to some other control completely. Whatever you do, I would
do it in a Subroutine and always use XXX (or whatever set of characters you
feel won't ever appear naturally in your text strings)...

Sub FakeLabel(TBox As TextBox, Caption As String, Replacement As String)
With TBox
.Text = Caption
.SelStart = InStr(.Text, "XXX")
.SelLength = 3
.SelText = Replacement
.SelBold = True
.SelStart = Len(Text1.Text) ' or OtherControl.SetFocus
End With
End Sub

This way, your inline code only has to do this...

FakeLabel Text1, "The variable is XXX blah blah.", SomeTextVariable

Rick
Back to top
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Mon Oct 09, 2006 5:55 pm    Post subject: Re: bold text in label Reply with quote

Rick Rothstein (MVP - VB) wrote:
>>>> I am putting text in a label as a variable. But i want just the
>>>> variable text to be bold face, so like:
>>>>
>>>> The variable is value of the variable blah blah.
>>>
>>> Label1.FontBold = True
>>> -or-
>>> Label1.Font.Bold = True
>>
>> No i mean like i want half of the text to be bold and the other half
>> not bold.
>
> You can't... a Label doesn't support that functionality. You might
> consider using a TextBox with the Locked property set to True.

You mean a RichTextBox?
--
Working without a .NET?
http://classicvb.org/
Back to top
View user's profile Send private message
"Rick Rothstein \



Joined: 04 Oct 2007
Posts: 1584

PostPosted: Mon Oct 09, 2006 9:08 pm    Post subject: Re: bold text in label Reply with quote

>>>>> I am putting text in a label as a variable. But i want just the
>>>>> variable text to be bold face, so like:
>>>>>
>>>>> The variable is value of the variable blah blah.
>>>>
>>>> Label1.FontBold = True
>>>> -or-
>>>> Label1.Font.Bold = True
>>>
>>> No i mean like i want half of the text to be bold and the other half
>>> not bold.
>>
>> You can't... a Label doesn't support that functionality. You might
>> consider using a TextBox with the Locked property set to True.
>
> You mean a RichTextBox?

Yeah... I was thinking RichTextBox and writing TextBox. Thanks for catching
that.

Corrected code for 'spitapps' (with a minor changes to make it work
correctly)...

Sub FakeLabel(RTBox As RichTextBox, Caption As String, _
Replacement As String)
With RTBox
.Text = Caption
.Find "XXX"
.SelBold = True
.SelText = Replacement
.SelStart = Len(Text1.Text) ' or OtherControl.SetFocus
End With
End Sub


Rick
Back to top
View user's profile Send private message
Sakkie



Joined: 04 Oct 2007
Posts: 1

PostPosted: Fri Oct 13, 2006 9:16 am    Post subject: Re: bold text in label Reply with quote

spitapps wrote:
> I am putting text in a label as a variable. But i want just the
> variable text to be bold face, so like:
>
> The variable is value of the variable blah blah.

Why don't you try using two labels instead
Back to top
View user's profile Send private message
Sneha Menon



Joined: 04 Oct 2007
Posts: 172

PostPosted: Fri Oct 13, 2006 10:44 pm    Post subject: Re: bold text in label Reply with quote

spitapps wrote:
> I am putting text in a label as a variable. But i want just the
> variable text to be bold face, so like:
>
> The variable is value of the variable blah blah.
----------------------------------------------------------------
Hi spitapps

I do not frequent this group, just happened to be here and saw your
posting.

Have you solved your problem? Settled on some solution??

Let me know

Sneha
--------------------------------------------------------------

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Label current text Hi, I have a main form that has data in it that is updated based upon a timer. The form has labels in it at get updated when the timer fires. I now want to open a second form, from the main form, that is not model. I have done this with this code: Dim f

How to use font bold in a msgbox???? Hi! I want to show a commum VB msgbox but I want part of the text to be in Bold (not all the text!), does anyone know if it's possible to do it using the function msgbox?? Thanks! Fernando Paes

Using a label with a Combo Box I have a VB.net form that is accessing a MS-SQL table via and DataSet. I have a cbo control bound to the field GuestName, and a label bound to GuestID. When I make the selection in the combo box the label doesn't change to the GuestID. This

Simple question about label captions Hello all. This is a simple question. I have a label on my form that displays data from a database field. No problem. What I want to do is to split this label up, with a first half of the text in black and a second half...if there is one, in red. The labe

display an icon when I point the mouse to the label Hi, I used to used this code below to display an icon when I point to a picture box, but this time I have a label instead of a picture box... (I put (I put = & "\move
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group