Solved

Changing font/size in a richtextbox using vb6

Posted on 2015-02-15
7
104 Views
Last Modified: 2015-02-16
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 ?
0
Comment
Question by:isnoend2001
  • 4
  • 2
7 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40611971
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

0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40612253
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

0
 

Author Comment

by:isnoend2001
ID: 40612495
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
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 46

Expert Comment

by:Martin Liss
ID: 40612509
Your Click event is empty! Add the code you posted originally and it will work.
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40612513
In other words

Private Sub cboSize_Click()

rtfLoan.SelFontSize = Val(cboSize.Text)
    rtfLoan.SetFocus
End Sub

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 40612531
Thanks, i had it in the change event, for future something else to double check
simple fix
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40612637
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
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

815 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now