• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

Bold and Italicts command

Dear friend my last question today. I need your help with the instruction to do the following task:

I have two command buttons called Italics and Bold. But i need the code for the buttons so that, when clicked, they toggle the state of the selected text in Text1.  That is, if the selected text is not in bold, pressing Bold will make it bold, but if it is already in bold, press in Bold returns it to non-bold.

What is the instruction to manipulate font on a text box??

Thanks,

Jairo
0
jcardenas
Asked:
jcardenas
1 Solution
 
AzraSoundCommented:
the command text1.fontbold turns on/off the bold property of the textbox.  if you say text1.fontbold = true then the bold is on. if you set it to false it will turn it off
0
 
jcardenasAuthor Commented:
Thank my friend, now my code is working fine with the Bold and Italicts buttons.

Regards,

Jairo Cardenas
Republic of Colombia
0
 
RuchiCommented:
Set the fontbold property to the opposite of what it currently equals by using the Not word.

Private Sub Command1_Click()
Text1.FontBold = Not Text1.FontBold
End Sub

Private Sub Command2_Click()
Text2.FontItalic = Not Text2.FontItalic
End Sub
0
 
Erick37Commented:
Use the RichTextBox control if you want to set the *selected* text to bold or italic:

Private Sub Command1_Click()
    'Toggle the Bold property of selected text
    rtb.SelBold = Not rtb.SelBold
End Sub

Private Sub Command2_Click()
    rtb.SelItalic = Not rtb.SelItalic
End Sub
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now