Solved

Changing font/size in a richtextbox using vb6

Posted on 2015-02-15
7
113 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
[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
  • 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 47

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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 47

Expert Comment

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

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 47

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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