Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspdotnet_website_programming thread: Re: Is there a VB .NET version for the code?


Message #1 by "Demian Martinez" <demianuco@h...> on Wed, 11 Sep 2002 13:25:56
I am developing a Visual Basic version of the code. It is a great way to 
learn both VB.NET and C#. The main challenge lies not simply in trying to 
figure out the best way to translate every line into VB, but rather in 
coming up with completely new ways to do the same thing when there are no 
VB.NET equivalents for C# statements.

A perfect example of this is the C# 'using' statement block used several 
times throughout the book to ensure that objects exist only within the 
block and are disposed upon exiting it. There is not VB.NET equivalent to 
this, although there is an elegant way to achieve the same result.

There are, of course, many simpler challenges that one encounters along 
the way, but there are challenges nevertheless. An examples is how 
C# 'static' methods are not 'static' in VB.NET, but rather 'shared'. Or 
for example, how VS.NET allows you to determine the DEFAULT namespace for 
a C# project, but instaead the ROOT namespace for a VB.NET, which means 
namespaces must be declared differently in each module of that project.

There are many more 'gotchas' like the one above. If I have time, I will 
document all of these and post them to the forum, in case anyone is 
interested. In the mean time, if anyone is having a tough time porting the 
code to VB.NET, let me know... I might have stumbled across the same 
problem.

Demian.
Message #2 by "Mike Gale" <info@d...> on Thu, 12 Sep 2002 08:36:20 +1200
Hi Demian,

Well done.  If you release this a lot of people will be interested.

There are resources (which you probably know about) but I'll mention
them for others on the list.

For a quick analysis of C# vs. VB.NET see
http://www.visualbasicexpert.com/vbvscsharp.htm
This lists a way to implement C# using in VB.NET.  (In my view this
problem is an anomaly, the design philosophy of "using" is very VB in
feel but it's only present in C#.  Strange!)

For language converters
Alex Lowe has a converter at
http://aspalliance.com/aldotnet

As does Kamal Patel at
http://www.kamalpatel.net/ConvertCSharp2VB.aspx

(In my comparisons I preferred Alex's for my test code.)

None of the above (as far as I can recall) handles the += syntax for
delegates from C# to VB.NET.  (Read your language manuals for this
one!!)

It is also easy to write a VB.NET ASPX site and still use the "C#
classes" behind that.

Mike Gale, Decision Engineering (NZ) Ltd.

PS.  As I said before I wouldn't be surprised if the authors launched a
VB.NET version of the book OR even a both languages version.

>I am developing a Visual Basic version of the code.

Message #3 by "Demian Martinez" <demianuco@h...> on Thu, 12 Sep 2002 16:44:21
Hi Mike,

Thanks for the resources on C# to VB.NET conversion. I found the links 
useful and translators interesting, they must have taken the authors a lot 
of work. You are right in saying that none handle the challenging 
conversions, such as the aforementioned 'using' statement or the += syntax 
for delegates. Incidentally, this is how I handled them:

C# Original Code:
this.Load += new System.EventHandler(this.PhilePage_Load)

VB.NET Equivalent:
AddHandler Me.Load, AddressOf PhilePage_Load

I have to say, I prefer VB.NET's explicitness and simplicity; both are 
always a good idea when programming.

I agree with you, I would not be surprised if the authors created a VB.NET 
version of the book, even if it were only in electronic PDF format. When 
they do, I will be very interested to see how they handled the conversion.

Thanks again for the links.

Demian.






> Hi Demian,

Well done.  If you release this a lot of people will be interested.

There are resources (which you probably know about) but I'll mention
them for others on the list.

For a quick analysis of C# vs. VB.NET see
http://www.visualbasicexpert.com/vbvscsharp.htm
This lists a way to implement C# using in VB.NET.  (In my view this
problem is an anomaly, the design philosophy of "using" is very VB in
feel but it's only present in C#.  Strange!)

For language converters
Alex Lowe has a converter at
http://aspalliance.com/aldotnet

As does Kamal Patel at
http://www.kamalpatel.net/ConvertCSharp2VB.aspx

(In my comparisons I preferred Alex's for my test code.)

None of the above (as far as I can recall) handles the += syntax for
delegates from C# to VB.NET.  (Read your language manuals for this
one!!)

It is also easy to write a VB.NET ASPX site and still use the "C#
classes" behind that.

Mike Gale, Decision Engineering (NZ) Ltd.

PS.  As I said before I wouldn't be surprised if the authors launched a
VB.NET version of the book OR even a both languages version.

>I am developing a Visual Basic version of the code.


  Return to Index