PRB: "Invalid Property Value" If TrueType Fonts Only SelectedLast reviewed: October 30, 1995Article ID: Q129934 |
The information in this article applies to:
SYMPTOMSIf 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 valueThis 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.FontNameThis 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
CAUSEMS 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.
RESOLUTIONIf 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 STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional reference words: 4.00 vb4win vb4all
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |