PRB: "Invalid Property Value" If TrueType Fonts Only Selected (129934)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Standard Edition for Windows 3.0
- Microsoft Visual Basic Professional Edition for Windows 3.0
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.
Modification Type: | Minor | Last Reviewed: | 1/8/2003 |
---|
Keywords: | kbprb KB129934 |
---|
|