BUG: Passing Variant Array to WriteFields Method Generates Error

Last reviewed: February 4, 1998
Article ID: Q180456
The information in this article applies to:
  • Windows CE Toolkit for Visual Basic 5.0, version 1.0

SYMPTOMS

When a Variant array is passed as a parameter, one of the following errors may occur:

   An error was encountered while running this program.

 -or-

   Subscript out of range.

RESOLUTION

To work around this behavior, pass arrays without parenthesis, as follows:

   File1.WriteFields sData

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The following code sample should write the array out as a comma-delimited line. Online documentation indicates that the parameter passed to the WriteFields Method can be a Variant or Variant array of numeric or string expressions.

Steps to Reproduce Behavior

  1. Create a new Windows CE Project in Visual Basic 5.0. Form1 is created by default. From the Project menu, select Components, check the "Microsoft CE File System Control 1.0" control, and then click OK.

  2. From the Windows CE menu, select Control Manager and then select the "File Class" list view item. From the Emulation menu, select Install. Add a File control and a Command Button to Form1.

  3. Add the following code to the project:

          Dim sData()
          Dim iLoop
          Private Sub Command1_Click()
    
             On Error Resume Next
             'Build Array
             ReDim sData(3)
             For iLoop = 0 To 3
                 sData(iLoop) = "Some Text" & iLoop
             Next
             File1.Open "\test.txt", 2
             File1.WriteFields sData()   'This line generates an error.
             MsgBox Err.Number & " " & Err.Description
             File1.Close
         End Sub
    
    

  4. Press the F5 key to run the project and note that a message box appears indicating that error 9 "subscript out of range" occurred.
Keywords          : vb5all vbce
Version           : WINDOWS:1.0
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 4, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.