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?
 
KDivadConnect With a Mentor Commented:
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
 
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
All Courses

From novice to tech pro — start learning today.