• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

RichText Font Change



Want to change font size for whole text in a RichTextBox

RichText.Filename=Name$ ' inputs text
' font size =10

RichText.SelLength=len(RichText.TextRTF) ' highlights all
RichText.Font.Size =12
RichText.SelLength=0

changes font size only up to the position where an attribute
like Underline or Bold is loacted within RTFtext,
how can this be fixed ?
0
MM070398
Asked:
MM070398
  • 2
1 Solution
 
jbilCommented:
RichText.SelFontSize = 12

instead of

RichText.Font.Size =12


0
 
MattiCommented:
Hi!

Best is use StdFont object it is simplest and fastest if you wan't it globaly in that rtf box.

Try this sample:

here are two command buttons for the test and one rtf box on a form.
Option Explicit


Dim myfont As New StdFont
'Need declare this

Private Sub Command1_Click()
myfont.Size = 10
Set RichTextBox1.Font = myfont
End Sub

Private Sub Command2_Click()
myfont.Size = 16
Set RichTextBox1.Font = myfont
End Sub

Private Sub Form_Load()
myfont.Bold = False
myfont.Name = "Arial"
myfont.Size = 10 ' A defaul font size in here
End Sub

Matti
0
 
MattiCommented:
Hi!

I think this problem a litle moore
and what if it is not the font is not the first matter in here.

Someting extra comes to my mind if you try to use clipboard data e.g Word 97 / 2000 documet. Then there is bossible that some format options like division into paragraphs e.g and that might need a filter control.

Another rtf box will do this.

Bring the documet to this second unvisible rtf box, and move it to other rtf box as text.

RichTextBox1.Text = RichTextBox2.Text

This will remove those special format options and the font conversion might get solved successful.

Matti
0
 
MM070398Author Commented:
RichText.SelFontSize = 12

instead of

RichText.Font.Size =12

from jbil works also
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now