URGENT! Font property

How can i set the same font name and size for all my labels,
textboxes and listboxe with a "single shot"? (i mean without write
the font property for each control: i have 200 labels and 40          textboxes!).
parduzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KDivadCommented:
Private Sub SetFormFontProp(SetForm As Form, ByVal FontN As String, ByVal FontS As Integer)

For Each TextCtrl In SetForm
On Error Resume Next
    If TypeOf TextCtrl Is TextBox Then
        TextCtrl.FontName = FontN
        TextCtrl.FontSize = FontS
    ElseIf TypeOf TextCtrl Is Label Then
        TextCtrl.FontName = FontN
        TextCtrl.FontSize = FontS
    End If
Next

End Sub

I don't mess with TypeOf very often, but you may be able to replace:

    If TypeOf TextCtrl Is TextBox Then
        TextCtrl.FontName = FontN
        TextCtrl.FontSize = FontS
    ElseIf TypeOf TextCtrl Is Label Then
        TextCtrl.FontName = FontN
        TextCtrl.FontSize = FontS
    End If

with:

    If TypeOf TextCtrl Is TextBox Or TypeOf TextCtrl Is Label Then
        TextCtrl.FontName = FontN
        TextCtrl.FontSize = FontS
    End If

Hope this helps!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
parduzAuthor Commented:
The right code is:

                     textctrl.Font.Name = FontN
                     textctrl.Font.Size = FontS

but your answer is right.

Thanks!

(Please Take a look at my other question, if you have time ;)
0
KDivadCommented:
Last I checked (VB5), VB still supported FontName and FontSize as valid properties, does it not support them anymore?
0
parduzAuthor Commented:
Yes, it is true (VB5), but the help says that are old properties, thats remains only for the CommonDialog control and the compatibilty with
old code.
So is better use the font.name or font.size property.
0
KDivadCommented:
ok, just wondering.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.