PRB: Passing Variant Array to WriteFields Method Generates Error

ID: Q180456


The information in this article applies to:
  • Microsoft Windows CE Toolkit for Visual Basic 6.0
  • Microsoft Windows CE Toolkit for Visual Basic 5.0


SYMPTOMS

When a Variant array is passed as a parameter, one of the following errors might 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

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

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


  2. In VBCE5 only: From the Windows CE menu, click Control Manager, and click File Class. From the Emulation menu, click 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.


Additional query words: wince vbce vbce5 vbce6

Keywords : kbToolkit kbVBp500 kbVBp600 kbWinCE100 kbGrpVB
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: October 18, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.