Export (0) Print
Expand All
Expand Minimize

As clause removed from variant ReDim

Visual Studio .NET 2003

In Visual Basic 6.0, a variable of the Variant data type could be changed to an array of a different data type using the ReDim keyword with an As clause.

When a Visual Basic 6.0 project is upgraded to Visual Basic .NET, any Variant variables are converted to the Object data type; you cannot define an object as a different data type using the As clause.

The following example shows the usage of the ReDim keyword:

' Visual Basic 6.0
Dim V As Variant
ReDim V(10) As Integer

' After upgrade to Visual Basic .NET
Dim V As Object
' UPGRADE_WARNING: As Integer was removed from ReDim V statement.
ReDim V(10)

What to do next

  • Modify your code so that the variable is initially declared as an array of the correct data type:
    ' Modified code
    Dim V() As Integer
    ReDim V(10)
    
  • Search your code to see if the variable is used anywhere else, and make sure that the data type is correct for each occurrence. Assign new variables if necessary for any additional data types.

See Also

ReDim Statement Changes in Visual Basic

Show:
© 2015 Microsoft