BUG: Application Error Returns Resized Array to Event Procedure (272400)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q272400

SYMPTOMS

When you attempt to assign the return value of a function to an event procedure array argument, an Application Error occurs if the function returns an array that is not the same size as the array argument in the event procedure.

RESOLUTION

To work around this behavior:
  • a temporary array can be used as the return for the function and the array argument can be resized in the event procedure.

    -or-

  • the array in the function can be re-dimensioned to the same size as the array in the event procedure.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new Visual Basic Standard EXE project. Form1 is created by default.
  2. On the Project menu, select Components. In the Components dialog box, select the Microsoft Windows Common Controls-2 6.0 component, and then click OK.
  3. Add a MonthView control to Form1.
  4. Add the following code to the General Declarations section of Form1:
    Private Sub MonthView1_GetDayBold(ByVal StartDate As Date, ByVal Count As Integer, State() As Boolean)
       State = ChangeArray(UBound(State))
    End Sub
    
    Function ChangeArray(UpperBound As Integer)
       Dim aryNew() As Boolean
       'Uncomment the following line to examine a workaround.
       'ReDim aryNew(UpperBound) As Boolean
       ChangeArray = aryNew
    End Function
  5. Press the F5 key to run the program and note that an Application Error occurs.

Modification Type:MajorLast Reviewed:10/15/2002
Keywords:kbBug kbCmnCtrls kbCtrl kbDSupport kbMonthCalCtrl KB272400