By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,712 Members | 1,591 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,712 IT Pros & Developers. It's quick & easy.

Convert 1 line of C# to VB.Net

P: n/a
Hi,

I am converting a code sample found at
http://support.microsoft.com/default...b;en-us;828279 from C#
to VB and I am stuck on one line of code. How would I convert:

object[] pos = new object[numaxes];

(where numaxes is an int) to VB.Net?

I have tried

Dim pos() As Object = New Object(numaxes)
,
Dim pos(numaxes) As Object = New Object

and

Dim pos As Object() = New Object
ReDim pos(numaxes)

but these attempts all generate errors

Thanks,

Stephen
Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Not 100% sure, but you can try - Dim pos(numaxes) As Object

"Stephen Miller" <js******@hotmail.com> wrote in message
news:cd**************************@posting.google.c om...
Hi,

I am converting a code sample found at
http://support.microsoft.com/default...b;en-us;828279 from C#
to VB and I am stuck on one line of code. How would I convert:

object[] pos = new object[numaxes];

(where numaxes is an int) to VB.Net?

I have tried

Dim pos() As Object = New Object(numaxes)
,
Dim pos(numaxes) As Object = New Object

and

Dim pos As Object() = New Object
ReDim pos(numaxes)

but these attempts all generate errors

Thanks,

Stephen

Nov 20 '05 #2

P: n/a
On 24 May 2004 19:30:16 -0700, Stephen Miller wrote:
Hi,

I am converting a code sample found at
http://support.microsoft.com/default...b;en-us;828279 from C#
to VB and I am stuck on one line of code. How would I convert:

object[] pos = new object[numaxes];

(where numaxes is an int) to VB.Net?

I have tried

Dim pos() As Object = New Object(numaxes)
,
Dim pos(numaxes) As Object = New Object

and

Dim pos As Object() = New Object
ReDim pos(numaxes)

but these attempts all generate errors

Thanks,

Stephen


Dim pos(numaxes) As Object

You should be aware that the array bounds semantics are different in VB.NET
then C#. Say numaxes = 5. In C#, the statement Object[] pos = new
Object[numaxes] would create a 5 element array with indexes 0 to 4. The
above VB.NET statement, will create a 6 element array with indexes 0 to 5.
Just another little gotcha when converting C# to VB.NET :)

HTH
--
Tom Shelton [MVP]
Nov 20 '05 #3

P: n/a
Hi Stephen Miller

Try this following code, this will work

Dim pos(numaxes) As Object

Array declarations in VB.NET is like this only. That syntax holds good only for C#

Sadha Sivam
Microsoft Community Star
Malleable Minds Software Pvt Ltd.
India.
Nov 20 '05 #4

P: n/a
From what I can see this is an Int16 type array declaration - so all
you need to do is declare an Array of type int - size numaxes. Do not
know much about c# though so could be wrong!!

Maybe try something like:

Dim pos(numaxes) As int16


js******@hotmail.com (Stephen Miller) wrote in message news:<cd**************************@posting.google. com>...
Hi,

I am converting a code sample found at
http://support.microsoft.com/default...b;en-us;828279 from C#
to VB and I am stuck on one line of code. How would I convert:

object[] pos = new object[numaxes];

(where numaxes is an int) to VB.Net?

I have tried

Dim pos() As Object = New Object(numaxes)
,
Dim pos(numaxes) As Object = New Object

and

Dim pos As Object() = New Object
ReDim pos(numaxes)

but these attempts all generate errors

Thanks,

Stephen

Nov 20 '05 #5

P: n/a
* js******@hotmail.com (Stephen Miller) scripsit:
I am converting a code sample found at
http://support.microsoft.com/default...b;en-us;828279 from C#
to VB and I am stuck on one line of code. How would I convert:

object[] pos = new object[numaxes];


\\\
Dim pos() As Object = New Object(numaxes - 1) {}
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6

P: n/a
Hi Herfried,

Tom wrote this already, however when this was really needed I would choise
in this case for
\\\
Dim pos() As Object = New Object(numaxes - 1) {}
///

Dim pos(numaxes - 1) As Object

I think that this looks more to VB.net than that C# code you provided.

It seems that you like the C# context more however I see no reason to show
that in a language.vb newsgroup.

Just my thought,

:-))))))

Cor
Nov 20 '05 #7

P: n/a
Hi Cor,

* "Cor Ligthert" <no**********@planet.nl> scripsit:
Tom wrote this already, however when this was really needed I would choise
in this case for
\\\
Dim pos() As Object = New Object(numaxes - 1) {}
///

Dim pos(numaxes - 1) As Object

I think that this looks more to VB.net than that C# code you provided.

It seems that you like the C# context more however I see no reason to show
that in a language.vb newsgroup.


It's still valid VB.NET syntax, and has nothing to do with C# syntax.
It's simply an alternative ;-))).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #8

P: n/a
Both of these methods work, however I have hit another snag converting
a subsequent line of code that uses the pos() object array. The C#
code uses the ref method parameter keyword:

ADOMD.Cell cell = oAdoMDCellSet.get_Item(ref pos);

What is the VB.Net equivilant to 'ref pos'?

I figured it may look like:

Dim cell As ADOMD.Cell = oAdoMDCellSet.get_Item(byref pos)

... but this generates errors

Thanks, for your suggestions

"Cor Ligthert" <no**********@planet.nl> wrote in message news:<Oq**************@tk2msftngp13.phx.gbl>...
Hi Herfried,

Tom wrote this already, however when this was really needed I would choise
in this case for
\\\
Dim pos() As Object = New Object(numaxes - 1) {}
///

Dim pos(numaxes - 1) As Object

I think that this looks more to VB.net than that C# code you provided.

It seems that you like the C# context more however I see no reason to show
that in a language.vb newsgroup.

Just my thought,

:-))))))

Cor

Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.