Solved

Bold and Italicts command

Posted on 2000-04-21
4
253 Views
Last Modified: 2010-05-02
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
Comment
Question by:jcardenas
4 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 10 total points
ID: 2738885
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
 

Author Comment

by:jcardenas
ID: 2738907
Thank my friend, now my code is working fine with the Bold and Italicts buttons.

Regards,

Jairo Cardenas
Republic of Colombia
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2738919
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
 
LVL 32

Expert Comment

by:Erick37
ID: 2738927
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question