.NETGURU
Upgrade Option Strict Issue
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.upgrade.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Chris Lane (VIP)
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

Reply to this message...
 
    
Jay B. Harlow [MVP - Outlook] (VIP)
Chris,
Try something like:

> Array = DirectCast(rsRow.GetRows(, , "somefield"), Object(,))

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

"Chris Lane" <Chris Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Chris Lane (VIP)
Thanks that might work.

"Jay B. Harlow [MVP - Outlook]" wrote:

[Original message clipped]

Reply to this message...
 
    
Jay B. Harlow [MVP - Outlook] (VIP)
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

"Chris Lane" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
tb anywhere
(Type your message here)

--------------------------------
From: tb anywhere

there is a tool which can upgrade vb to c#.
free download.
http://www.e-iceblue.com
Reply to this message...
 
    
Jack
(Type your message here)

--------------------------------
From: Jack
Hi , EveryOne :
There is a vb and vb.net to c# converter very well here,
I feel it very good . new version free download, why not try it ?
http://www.e-iceblue.com
Reply to this message...
 
    
Jack
(Type your message here)

--------------------------------
From: Jack
Hi , EveryOne :
There is a vb and vb.net to c# converter very well here,
I feel it very good . new version free download, why not try it ?
http://www.e-iceblue.com
Reply to this message...
 
 
System.Object




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification