I am try to convert over to NET from VB 6, I have some arrays from VB6 that were variant, when I converted them
to NET they went to objects. For example:
dim dblarray as object (which was variant in VB6)
dim strname as string
dim introw as integer
strname = "A/R"
dblarray(intRow, 4) = name
I get this error
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
Additional information: Cast from string "A/R" to type 'Double' is not valid.
it worked in VB6, how do I fix this, any help would be appreciated
National Steel Car
905-544-3317 ex 3341
Posted by: Paul MartzPost date: 11/4/2005 1:21:58 AM
In .Net you have to be a bit more specific about arrays.
Try something like this
Dim dblArray(1, 1) As Object
This creates a 2-Dimensional Array of Objects with 2 element in each dimension - 4 Elements in total dblArray(0,0) dblArray(0,1) dblArray(1,0) and dblArray(1,1).
to redefine the array use ReDim making sure to use Preserve if you want to keep the existing content e.g.
ReDim Preserve dblArray(2,2) 'Now the array has 3 elements in each dimension.
Hope this helps
Posted by: Calum McLellanPost date: 11/6/2005 7:06:52 AM