?
Solved

Bold and Italicts command

Posted on 2000-04-21
4
Medium Priority
?
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 40 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 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