Library code snippets

Displaying all system fonts in a combobox!

This trick show you how to add display all the fonts, which you have installed on your system, in a combobox.
On my computer, it takes some time because I have installed about 1050 fonts but I think most of the computers have about 500 fonts but anyway.
Don't worry if your your computer freezes for some seconds. If you want the fonts to be sorted(A to Z) then set its "sorted" property to true.
Here is the code:

Dim i As Long
Private Sub Form_Load()
For i = 0 To Screen.FontCount - 1
Combo1.AddItem Screen.Fonts(i)
Next
End Sub

Comments

  1. 18 Jul 2005 at 18:14

    Another way to check if a font is installed:


    Private Function IsFontInstalled(FaceName As String) As Boolean
       Dim fnt As New StdFont
       ' Try assigning the facename
       fnt.Name = FaceName
       ' Compare to see if the assignment took
       IsFontInstalled = (fnt.Name = FaceName)
    End Function

  2. 24 Jul 2004 at 15:21
    Thank you, thank you, thank you!

    I've been looking for this. I was sure there has to be a "special" command, but didn't know what it was. You saved me a lot of brain-ache
  3. 01 Jan 1999 at 00:00

    This thread is for discussions of Displaying all system fonts in a combobox!.

Leave a comment

Sign in or Join us (it's free).

 Abdul

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!