Results 1 to 4 of 4

Thread: How to change the Font Name globally??

  1. #1

    Thread Starter
    Member AnsMe's Avatar
    Join Date
    Sep 2001
    Posts
    63

    How to change the Font Name globally??

    I have 10 forms(of course with VB controls - textbox,listbox,labels,command buttons etc) and want to know if there is a way "to change all the controls default fonts" to a different font across all Forms.

    Thanx
    When you TELL THE TRUTH, you don't have to REMEMBER WHAT YOU SAID !!!

  2. #2
    New Member
    Join Date
    Oct 2001
    Location
    UK
    Posts
    2
    I had the same problem on a project with 28 forms and there's no easy way that I could find.

    If you've only used the controls that ship with VB then you might get away with doing a search and replace on your .frm files, replacing "MS Sans Serif" with "Arial", but this doesn't work in all cases. You'd have to use a text editor, not VB itself.

    Bear in mind that with VB6 (maybe 5 also) if you set the font on the form before you draw any controls, all the controls will inherit the font for the form. Next time, set Arial as the font on your empty form before you start designing it.

    - Andy.

  3. #3

    Thread Starter
    Member AnsMe's Avatar
    Join Date
    Sep 2001
    Posts
    63
    Thanx for information.
    When you TELL THE TRUTH, you don't have to REMEMBER WHAT YOU SAID !!!

  4. #4
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    yeah it isnt too hard
    In each form's formload event just do this

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim lCtrl As Control
    3.     For Each lCtrl In Me.Controls
    4.         'Add an OR for each type of control
    5.         If TypeOf lCtrl Is TextBox Then lCtrl.FontName = "Arial"
    6.     Next
    7. End Sub

    Or if u dont mind doing Resume next u can just do this
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim lCtrl As Control
    3.     On Error Resume Next
    4.     For Each lCtrl In Me.Controls
    5.         lCtrl.FontName = "Arial"
    6.     Next
    7. End Sub
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width