Article ID: 129934
Article Last Modified on 1/8/2003
APPLIES TO
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 16-bit Enterprise Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
- Microsoft Visual Basic 3.0 Professional Edition
- Microsoft Visual Basic 3.0 Professional Edition
This article was previously published under Q129934
SYMPTOMS
If you have "TrueType fonts only" set in the Fonts applet in the Windows
Control Panel, when you execute Visual Basic code that sets a Fontname
property of a form or control to "MS Sans Serif" (or any other non-TrueType
font), the program generates error 380:
Invalid property value
This error can also be generated when you execute the following statement
if the FontName property of the Form is a Non-TrueType font (which it is by
default):
Form1.FontName = Form1.FontName
This is true even though the default FontName value is MS Sans Serif.
This is because the FontName property is set by default to a non-TrueType
font. If you change the FontName property to Arial at design time, you will
not get the "Invalid property Value" error, because Arial is a TrueType
Font
CAUSE
MS Sans Serif is the default font for every control created in Visual
Basic. Visual Basic does not detect the 'True Types only' setting in
the Fonts applet and is, therefore, unaware of the fact that "MS Sans
Serif" is an invalid font choice. When the program causes an assignment of
the Fontname, Visual Basic is bound to the 'True Types only' setting and
rejects any Fontnames not on the list.
RESOLUTION
If you need to set your Fontname property, you can guarantee that the
font chosen is valid by stepping through the Screen.Fonts collection with
this code:
Private Sub Form_Load()
Dim AFontName As String
Dim ItsLegal As Integer
AFontName = "MS Sans Serif"
For I = 1 To Screen.FontCount - 1
If AFontName = Screen.Fonts(I) Then
ItsLegal = True
Exit For
End If
Next
If ItsLegal Then
Form1.FontName = AFontName
Else
MsgBox AFontName & " is not available."
End If
End Sub
STATUS
This behavior is by design.
Additional query words: 4.00 vb4win vb4all
Keywords: kbprb KB129934