all groups > vb.net upgrade > june 2004 >
You're in the

vb.net upgrade

group:

Upgrade Option Strict Issue


Upgrade Option Strict Issue Chris Lane
6/30/2004 2:20:02 PM
vb.net upgrade:
Hi,

I upgraded a VB6.0 application that uses the GetRows method to return a 2 dimensional array into a variable of type variant.
In VB.NET the Variant variable is of type object but since it's a two dimensional array I changed it to the following:

Dim Array (,) as Object

On this line:
Array = rsRow.GetRows(, , "somefield")
Now Option strict is barking:
Option Strict On disallows implicit conversions from 'System.Object' to '2-dimensional array of System.Object'.

Can I type cast this two a two dimesional array?
If not what else can I do?
Since this project is not funded I am trying to avoid converting ado code to ado.net code but if that is the only solution I will have to.

Thank You,

Chris Lane
Re: Upgrade Option Strict Issue Jay B. Harlow [MVP - Outlook]
7/1/2004 8:37:49 AM
Chris,
Try something like:

[quoted text, click to view]

The above was syntax checked only, if RecordSet.GetRows does not return a
two dimension array of objects, you will get a runtime error.

Hope this helps
Jay


[quoted text, click to view]

Re: Upgrade Option Strict Issue Chris Lane
7/1/2004 2:29:04 PM
Thanks that might work.

[quoted text, click to view]
Re: Upgrade Option Strict Issue Jay B. Harlow [MVP - Outlook]
7/4/2004 7:03:15 PM
Chris,
Actually I should add, when I'm not certain of the return type (from GetRows
for example) I will use Option Strict Off, and assign the return value to an
Object variable, then look at the variable in one of the Watch windows in
the debugger...

Dim rc As Object
rc = rsRow.GetRows(, , "somefield")

Looking at "rc" in the Auto Watch Window for example will identify the type
that GetRows returned...

Hope this helps
Jay


[quoted text, click to view]

AddThis Social Bookmark Button