Solved

Bold and Italicts command

Posted on 2000-04-21
4
244 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now