Microsoft KB Archive/180456

= PRB: Passing Variant Array to WriteFields Method Generates Error =

Article ID: 180456

Article Last Modified on 3/11/2005

-

APPLIES TO


 * Microsoft eMbedded Visual Basic 3.0
 * Microsoft Windows CE Toolkit for Visual Basic 6.0

-



This article was previously published under Q180456



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

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.



Steps to Reproduce Behavior
 Create a new Windows CE project in eMbedded Visual Basic or Visual Basic 6.0. Form1 is created by default. From the Project menu, click Components, select "Microsoft CE File System Control", and click OK. Add a File control and a Command Button to Form1.  Paste the following code in to Form1: 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  Press F5 to run the project and note that a message box appears indicating that error 9 "subscript out of range" occurred.</ol>

Additional query words: wince vbce vbce6 evb

Keywords: kbtoolkit kbprb kbpending KB180456

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.