Knowledge Base

BUG: Incorrect Error Assigning Read-Only Property of UserControl

Article ID: 198887

Article Last Modified on 5/13/2003


APPLIES TO


This article was previously published under Q198887

SYMPTOMS

When you attempt to assign a value to a read-only property of a UserControl object, the following error message is displayed. However, the error message is incorrect.
Compile Error: Wrong number of arguments or invalid property assignment.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Standard EXE project in Microsoft Visual Basic. Form1 is created by default.
  2. From the Project menu, select Add User Control to add a UserControl object to the project.
  3. Paste the following code into the code window of the UserControl:
       Property Get Test() As Integer
          Test = 10
       End Property
    					
  4. Close the UserControl design window. This enables the UserControl object on the Toolbox.
  5. Add the UserControl object to Form1 by dragging the UserControl object from the Toolbox to Form1.
  6. Paste the following code in the declarations section of Form1:
       Private Sub Form_Load()
          UserControl11.Test = 10
       End Sub
    					
  7. Press the F5 key to run the project. The following error message is displayed:
    Compile Error: Wrong number of arguments or invalid property assignment.
    The expected error message is:
    Compile Error: Can't assign to read-only property.

Keywords: kbbug kbctrl kbpending KB198887