Solved

RichTextBox

Posted on 2014-04-03
2
209 Views
Last Modified: 2014-04-07
What formatting characters do I put in a string of text to make the characters bold and increase the font size when it’s put in a RitchTextBox.


Example:

Dim sTemp As String

sTemp = "This is some sample data " & vbCrLf
sTemp = sTemp & "Make this line Bold and Font Size 13" & vbCrLf
sTemp = sTemp & "Return to font size 10 and not bold "

RichTextBox.TextRTF = sTemp
0
Comment
Question by:PhilChapmanJr
2 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 39976054
You have to look at the RTF formatting.

The easiest way I've found to do this is create an RTF doc in wordpad.

Put something like bold test on the 1 line
and then look at the formatting form there.

Word has additional things that it can do but not all of them are supported by the .Net rich text box.
0
 
LVL 28

Accepted Solution

by:
Ark earned 500 total points
ID: 39981060
Any reason not using standard rtb way?
Private Sub Command1_Click()
   With RichTextBox1
      .Text = ""
      .SelText = "Normal" & vbCrLf
      
      .SelBold = True
      .SelFontSize = 13
      .SelText = "Bold with font size = 13" & vbCrLf
      
      .SelBold = False
      .SelFontSize = .Font.Size
      .SelText = "Normal again"
   End With
End Sub

Open in new window

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.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

679 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