Solved

Changing font/size in a richtextbox using vb6

Posted on 2015-02-15
7
97 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
Comment Utility
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 45

Expert Comment

by:Martin Liss
Comment Utility
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
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
Your Click event is empty! Add the code you posted originally and it will work.
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
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
Comment Utility
Thanks, i had it in the change event, for future something else to double check
simple fix
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

763 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

10 Experts available now in Live!

Get 1:1 Help Now