Link to home
Start Free TrialLog in
Avatar of isnoend2001
isnoend2001Flag for United States of America

asked on

Changing font/size in a richtextbox using vb6

one combo has the available font names
the other the font sizes
After i select Text in the rtf  and click out of the rtf it looses focus and nothing gets changed.
Example:
Private Sub cboSize_Click()
 rtfLoan.SelFontSize = Val(cboSize.Text)
    rtfLoan.SetFocus
End Sub

Open in new window

How to overcome this ?
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Don't know why.
Does this tell you anything?
Private Sub cboSize_Click()
    With rtfLoan
        Debug.Print 1, .SelStart, .SelLength, cboSize.Text
        .SelFontSize = cboSize.Text
        .SetFocus
        Debug.Print 2, .SelStart, .SelLength, cboSize.Text
    End With
End Sub

Open in new window

Can you post a zip file of your project?

Are you aware that you can use a CommonDialog control to change everything about a RichTextbox's font?

   
With MyCommonDialog
        .CancelError = True
        .Flags = cdlCFBoth Or cdlCFApply Or cdlCFEffects
        .ShowFont
        rtbEditor.SelFontName = .FontName
        rtbEditor.SelFontSize = .FontSize
        rtbEditor.SelItalic = .FontItalic
        rtbEditor.SelBold = .FontBold
        rtbEditor.SelUnderline = .FontUnderline
        rtbEditor.SelStrikeThru = .FontStrikethru
        rtbEditor.SelColor = .Color
    End With

Open in new window

Avatar of isnoend2001

ASKER

Thanks guys but the problem remains.
Yes I know that the CommonDialog control can be used, but is unneeded and have called the one on the users machine in the past to keep my app small.
Zip is included
-Font-Problem.zip
Your Click event is empty! Add the code you posted originally and it will work.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, i had it in the change event, for future something else to double check
simple fix
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014