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

Converting Vb.net to C# issues

P: n/a
I'm learning C# by converting a large asp.net project to C# that was written
in vb.net and option strict was turned off so it's a nice challenge and it
is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some say
VB.Net is more productive that C# albeit less safe with option strict turned
off.

My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date functions
and other things where a good map would come in handy.

Thanks,
T
May 21 '06 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Tina,

There isn't always a one-to-one mapping of the functions that are native
VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of classes
in the Microsoft.VisualBasic namespace.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some say
VB.Net is more productive that C# albeit less safe with option strict
turned off.

My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date functions
and other things where a good map would come in handy.

Thanks,
T

May 21 '06 #2

P: n/a
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way in
C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code you
wind up with is more Object-Oriented (IMHO) and easier to convert should
that become an issue.

There are also those out there that disagree with me and say that you should
feel free to use the Microsoft.VisualBasic Namespace, because that IS one of
the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my legacy
ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uQ**************@TK2MSFTNGP03.phx.gbl...
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option strict
turned off.

My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T


May 21 '06 #3

P: n/a
Download the demo edition of our Instant C# VB to C# converter. You can see
how many of the VisualBasic namespace methods are translated (we translate
the methods the have one-to-one equivalents in the framework, or nearly
one-to-one).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"Tina" wrote:
I'm learning C# by converting a large asp.net project to C# that was written
in vb.net and option strict was turned off so it's a nice challenge and it
is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some say
VB.Net is more productive that C# albeit less safe with option strict turned
off.

My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date functions
and other things where a good map would come in handy.

Thanks,
T

May 21 '06 #4

P: n/a
"Tina" <ti**********@nospammeexcite.com> wrote:
My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date functions
and other things where a good map would come in handy.


I would use .NET Reflector to see how the VisualBasic assembly methods
are implemented.

-- Barry

--
http://barrkel.blogspot.com/
May 21 '06 #5

P: n/a
Is there any way to disable use of the VisualBasic namespace when developing
in VB?
T
"Scott M." <s-***@nospam.nospam> wrote in message
news:ek****************@TK2MSFTNGP02.phx.gbl...
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way
in C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code
you wind up with is more Object-Oriented (IMHO) and easier to convert
should that become an issue.

There are also those out there that disagree with me and say that you
should feel free to use the Microsoft.VisualBasic Namespace, because that
IS one of the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my
legacy ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:uQ**************@TK2MSFTNGP03.phx.gbl...
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option
strict turned off.

My question is: Is there any docs, anywhere, that map C# methods that
are the counterpart of methods in the visualbasic namespace? I have
already found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T



May 21 '06 #6

P: n/a
Scott,
You are to be commended! Right now I'm forced to write some VB.NET code in
an ASP.NET 1.1 App that was totally written in VB.NET and can't be converted.
And I keep typing semicolons at the end of each line of code! Yeesh!
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Scott M." wrote:
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way in
C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code you
wind up with is more Object-Oriented (IMHO) and easier to convert should
that become an issue.

There are also those out there that disagree with me and say that you should
feel free to use the Microsoft.VisualBasic Namespace, because that IS one of
the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my legacy
ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uQ**************@TK2MSFTNGP03.phx.gbl...
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option strict
turned off.

My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T



May 22 '06 #7

P: n/a
No, there is no way to "remove" the built-in reference to the
Microsoft.VisualBasic Assembly in a VB.NET project. It's baked right in.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tina" wrote:
Is there any way to disable use of the VisualBasic namespace when developing
in VB?
T
"Scott M." <s-***@nospam.nospam> wrote in message
news:ek****************@TK2MSFTNGP02.phx.gbl...
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way
in C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code
you wind up with is more Object-Oriented (IMHO) and easier to convert
should that become an issue.

There are also those out there that disagree with me and say that you
should feel free to use the Microsoft.VisualBasic Namespace, because that
IS one of the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my
legacy ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:uQ**************@TK2MSFTNGP03.phx.gbl...
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option
strict turned off.

My question is: Is there any docs, anywhere, that map C# methods that
are the counterpart of methods in the visualbasic namespace? I have
already found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T



May 22 '06 #8

P: n/a
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Is there any way to disable use of the VisualBasic namespace when
developing in VB?


Unfortunately not.
May 22 '06 #9

P: n/a

Mark Rae wrote:
"Tina" <ti**********@nospammeexcite.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Is there any way to disable use of the VisualBasic namespace when
developing in VB?


Unfortunately not.


You and Peter Bromberg both said this. However, I seem to be able in
VB2005 Express to uncheck Microsoft.VisualBasic from the list of
project references, causing lines such as this

Dim d As DateTime = Today

to fail to compile. What gives?

Oh, and what's the C# for 'today' ?

--
Larry Lard
Replies to group please

May 22 '06 #10

P: n/a
DateTime.Today

Marc
May 22 '06 #11

P: n/a
You are writing VB.NET (1.1) that was totally written in VB.NET and can't be
converted? Do you mean it *was* VB 6.0 and now needs to be VB.NET?
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:E4**********************************@microsof t.com...
Scott,
You are to be commended! Right now I'm forced to write some VB.NET code in
an ASP.NET 1.1 App that was totally written in VB.NET and can't be
converted.
And I keep typing semicolons at the end of each line of code! Yeesh!
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Scott M." wrote:
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way
in
C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all
when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead
of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code
you
wind up with is more Object-Oriented (IMHO) and easier to convert should
that become an issue.

There are also those out there that disagree with me and say that you
should
feel free to use the Microsoft.VisualBasic Namespace, because that IS one
of
the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my
legacy
ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:uQ**************@TK2MSFTNGP03.phx.gbl...
> Tina,
>
> There isn't always a one-to-one mapping of the functions that are
> native VB as opposed to what is typically exposed in C#.
>
> I don't know of such a document, but if you post the methods here
> that
> you are having trouble with, I'm sure we can pose alternatives.
>
> Also, you can set a reference to Microsoft.VisualBasic.dll, and then
> access the methods in C#, as they are just static methods exposed of
> classes in the Microsoft.VisualBasic namespace.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard.caspershouse.com
>
> "Tina" <ti**********@nospammeexcite.com> wrote in message
> news:OS**************@TK2MSFTNGP02.phx.gbl...
>> I'm learning C# by converting a large asp.net project to C# that was
>> written in vb.net and option strict was turned off so it's a nice
>> challenge and it is really teaching me C#.
>>
>> This project used a lot of methods in the VisualBasic Namespace.
>> These
>> methods are really valuable and it seems they might be the reason some
>> say VB.Net is more productive that C# albeit less safe with option
>> strict
>> turned off.
>>
>> My question is: Is there any docs, anywhere, that map C# methods that
>> are
>> the counterpart of methods in the visualbasic namespace? I have
>> already
>> found that the String class has a lot of them but there are date
>> functions and other things where a good map would come in handy.
>>
>> Thanks,
>> T
>>
>
>


May 23 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.