Microsoft KB Archive/181414

{| The information in this article applies to:
 * width="100%"|
 * Microsoft Visual Basic Control Creation, Learning, Professional, and Enterprise Editions for Windows, version 5.0

SYMPTOMS
An ActiveX control created in Visual Basic contains font properties. When this control is used in a Web authoring environment, such as FrontPage or the ActiveX Control Pad, the Web authoring environment crashes or produces the following error:

Run-time error '50003': Unexpected Error

CAUSE
Visual Basic is attempting to write the font properties to an Object type in the property bag.

RESOLUTION
To persist font information for an ActiveX control that will be used in an HTML document, write out each font property separately to the property bag. This solution is illustrated in the MORE INFORMATION section of this article.

STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION
The following code for a sample control illustrates this problem. Notice that a font object is written to the property bag:

Private m_Font As New StdFont 'defines as Font object

Private Sub UserControl_InitProperties m_Font.Bold = False m_Font.Italic = False m_Font.Name = "Arial" m_Font.Size = 10 m_Font.Strikethrough = False m_Font.Underline = False End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag) On Error Resume Next Set m_Font = PropBag.ReadProperty("Font") End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag) PropBag.WriteProperty "Font", m_Font End Sub To correct this problem, write each font property separately to the property bag, as in this example: Private m_Font As New StdFont 'defines as Font object

Private Sub UserControl_InitProperties m_Font.Bold = False m_Font.Italic = False m_Font.Name = "Arial" m_Font.Size = 10 m_Font.Strikethrough = False m_Font.Underline = False End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag) On Error Resume Next m_Font.Bold = PropBag.ReadProperty("FontBold") m_Font.Italic = PropBag.ReadProperty("FontItalic") m_Font.Name = PropBag.ReadProperty("FontName") m_Font.Size = PropBag.ReadProperty("FontSize") m_Font.Strikethrough = PropBag.ReadProperty("FontStrikethrough") m_Font.Underline = PropBag.ReadProperty("FontUnderline") End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag) PropBag.WriteProperty "FontBold", m_Font.Bold PropBag.WriteProperty "FontItalic", m_Font.Italic PropBag.WriteProperty "FontName", m_Font.Name PropBag.WriteProperty "FontSize", m_Font.Size PropBag.WriteProperty "FontStrikethrough", m_Font.Strikethrough PropBag.WriteProperty "FontUnderline", m_Font.Underline End Sub
 * }

-

Last reviewed: February 20, 1998

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.