Fill a combo box with system fonts

Level:
Level1

Every system has many many fonts on it. Visual Basic allows us access to these fonts through its Screen object. Often getting font information can be very challenging, especially in the past using languages such as C++ or interacting directly through the Win32 API. Visual Basic makes this very easy. The source code below demonstrates this. It also demonstrates how you can use a for loop to loop through all the fonts. Lastly the source code demonstrates using a combo box control.

To use this source code sample simply create a new Visual Basic program, add a command button and a combo box to it. Double click on the command button to get into its click event handler method and add the code below.

  1. Private Sub Command1_Click()
  2.         Dim I As Integer
  3.         For I = 1 To Screen.FontCount - 1
  4.                 Combo1.AddItem Screen.Fonts(I)
  5.         Next
  6. End Sub

Obviously this is just the start to a program. You may for example want to allow the user to select a font and then apply that font to a text box or something else you have in your program.

Note: The source for this was found at DreamVB which is no longer online.

If you enjoyed this post, subscribe for updates (it's free)

about project

please project based on connectivity of vb6 to oracle

Fill a combo box with system fonts

please let me,how update your above programe for change text in rich text box

thank you

thank you for this ode
i really needed it for my own notepad
thank you very much
the best site ever

Font sizes

How do you also let the user select a font size that will match what is available for the chosen font.