Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Bold and Italicts command

Posted on 2000-04-21
4
Medium Priority
?
274 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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

609 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