Solved

Changing font/size in a richtextbox using vb6

Posted on 2015-02-15
7
127 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
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!

 
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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

729 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