Learning VB.NET??
-
Last week I got a project with one of the offices in the local goverment (we had been negotiating for about two months). Today I met with the systems office of the government, and he said that he had read my proposal and that he liked very much, but that he wanted me to do it in VB.NET instead of C#, and using Oracle as a database instead of my proposed SQL Server. It's an ASP.NET application that won't have a lot of traffic, so I was planning on using MSDE. The database choice is OK because all their databases run on Oracle, and they already have scheduled backups and maintaince. I'm fine with it. And the reason for using VB.NET instead of C# is because all his people (who are supposed to maintain my app in the future) use it, and most don't know C#. I still tried to persuade him, but finally I agreed. I've never used VB.NET, so, will I have any troubles? I've used QuickBasic and Visual Basic in the past, but I've since got used to C#. Other that fighthing with the syntax at the beginning, are there any features from C# I will miss? Or is there any possibility that I'll like it and never return to C#? :omg: -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
-
Last week I got a project with one of the offices in the local goverment (we had been negotiating for about two months). Today I met with the systems office of the government, and he said that he had read my proposal and that he liked very much, but that he wanted me to do it in VB.NET instead of C#, and using Oracle as a database instead of my proposed SQL Server. It's an ASP.NET application that won't have a lot of traffic, so I was planning on using MSDE. The database choice is OK because all their databases run on Oracle, and they already have scheduled backups and maintaince. I'm fine with it. And the reason for using VB.NET instead of C# is because all his people (who are supposed to maintain my app in the future) use it, and most don't know C#. I still tried to persuade him, but finally I agreed. I've never used VB.NET, so, will I have any troubles? I've used QuickBasic and Visual Basic in the past, but I've since got used to C#. Other that fighthing with the syntax at the beginning, are there any features from C# I will miss? Or is there any possibility that I'll like it and never return to C#? :omg: -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
Luis Alonso Ramos wrote: Or is there any possibility that I'll like it and never return to C#? Have no fear my friend :) If you have done VB or QB in the past, VB.NET will be a breeze for you, especially since you know the Framework. Essentially, it's the same thing with syntax differences. O'Reilly have a great pocket reference book for converting between C# and VB.NET. I have it and I like it. Here it is.[^] The WORSE that could happen to you, is that you can't come back to C# because you forgot its syntax! You'd then be on the VB.NET side forever. ;P
-
Last week I got a project with one of the offices in the local goverment (we had been negotiating for about two months). Today I met with the systems office of the government, and he said that he had read my proposal and that he liked very much, but that he wanted me to do it in VB.NET instead of C#, and using Oracle as a database instead of my proposed SQL Server. It's an ASP.NET application that won't have a lot of traffic, so I was planning on using MSDE. The database choice is OK because all their databases run on Oracle, and they already have scheduled backups and maintaince. I'm fine with it. And the reason for using VB.NET instead of C# is because all his people (who are supposed to maintain my app in the future) use it, and most don't know C#. I still tried to persuade him, but finally I agreed. I've never used VB.NET, so, will I have any troubles? I've used QuickBasic and Visual Basic in the past, but I've since got used to C#. Other that fighthing with the syntax at the beginning, are there any features from C# I will miss? Or is there any possibility that I'll like it and never return to C#? :omg: -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
A couple of hints you may find helpful. First, open up the IDE->Tools->Options->Project->VB Defaults, and make sure to make Option Strict On the default option so that you don't have to do so for every project. Second, by default C# allows you to edit code while in debug mode, VB does not. If you want to change this, open up the IDE->Tools->Options->Debugging-Edit & Continue, and check the option 'allow me to edit VB files while debugging' Third, you may or may not want to modify the VB text editor properties, perhaps decrease the indent size, etc... to do so, open up the IDE->Tools->Options->Text Editor->Basic and take a look and see what you like and what you don't like. Fourth, you may or may not want to for each and every VB project, Project->Properties->Commom Properties->General, and remove the rootnamespace value only so that you have to explicitly declare the any and all namespaces the way you're use to in C#. The only reason I make a habit of doing this is just to make the coding habits standard whenever I switck back and forth just to avoid confusion. Fifth, you may or may not want to remove all the global project imports (include) from your VB project so that you're forced to explicitly include any namespace you use in the code file. Again, sometimes it's useful to include for example the System namespace just to avoid having to do so manually for each code file, however, just to keep the coding habits standard across both languages and thereby avoid possible confusion when having to switch back and forth, I would recommend that you always remove all global project imports, although I will admit that I fine this feature useful, especially during UI development when I just want to get it over with as soon as possible. Project->Properties->Commom Properties->Imports Sixth, if possible given your project, Project->Properties->Configuration Properties->Optimizations, remove integer overflow checks and enable optimizations. Why this is not the default is beyond me. Seven, Project->Properties->Configuration Properties->Build, you may or may not want to treat compiler warnings as errors. VB is the easiest language in the world so don't even worry about it. Suerte!
-
Luis Alonso Ramos wrote: Or is there any possibility that I'll like it and never return to C#? Have no fear my friend :) If you have done VB or QB in the past, VB.NET will be a breeze for you, especially since you know the Framework. Essentially, it's the same thing with syntax differences. O'Reilly have a great pocket reference book for converting between C# and VB.NET. I have it and I like it. Here it is.[^] The WORSE that could happen to you, is that you can't come back to C# because you forgot its syntax! You'd then be on the VB.NET side forever. ;P
Carl Mercier wrote: VB.NET will be a breeze for you Yes, I'm actually expecting that. I was just asking for some aspects of the language I will miss (I can think of XML comments -- I usually use them a lot to get a documentation of the code, public or not.) Carl Mercier wrote: you can't come back to C# because you forgot its syntax! You'd then be on the VB.NET side forever No way!! I can always relearned it! ;P -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
-
A couple of hints you may find helpful. First, open up the IDE->Tools->Options->Project->VB Defaults, and make sure to make Option Strict On the default option so that you don't have to do so for every project. Second, by default C# allows you to edit code while in debug mode, VB does not. If you want to change this, open up the IDE->Tools->Options->Debugging-Edit & Continue, and check the option 'allow me to edit VB files while debugging' Third, you may or may not want to modify the VB text editor properties, perhaps decrease the indent size, etc... to do so, open up the IDE->Tools->Options->Text Editor->Basic and take a look and see what you like and what you don't like. Fourth, you may or may not want to for each and every VB project, Project->Properties->Commom Properties->General, and remove the rootnamespace value only so that you have to explicitly declare the any and all namespaces the way you're use to in C#. The only reason I make a habit of doing this is just to make the coding habits standard whenever I switck back and forth just to avoid confusion. Fifth, you may or may not want to remove all the global project imports (include) from your VB project so that you're forced to explicitly include any namespace you use in the code file. Again, sometimes it's useful to include for example the System namespace just to avoid having to do so manually for each code file, however, just to keep the coding habits standard across both languages and thereby avoid possible confusion when having to switch back and forth, I would recommend that you always remove all global project imports, although I will admit that I fine this feature useful, especially during UI development when I just want to get it over with as soon as possible. Project->Properties->Commom Properties->Imports Sixth, if possible given your project, Project->Properties->Configuration Properties->Optimizations, remove integer overflow checks and enable optimizations. Why this is not the default is beyond me. Seven, Project->Properties->Configuration Properties->Build, you may or may not want to treat compiler warnings as errors. VB is the easiest language in the world so don't even worry about it. Suerte!
Giancarlo Aguilera wrote: Option Strict On If I remember correctly, that makes me declare all variables prior to using them, doesn't it? Any other things it does? Giancarlo Aguilera wrote: you may or may not want to treat compiler warnings as errors I always do. Giancarlo Aguilera wrote: VB is the easiest language in the world so don't even worry about it. Actually I'm not worried. I've used Visual Basic before, so I know the syntax. I just expect a few days of again getting used to it... like putting semicolons after statements, for example. :) -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
-
Carl Mercier wrote: VB.NET will be a breeze for you Yes, I'm actually expecting that. I was just asking for some aspects of the language I will miss (I can think of XML comments -- I usually use them a lot to get a documentation of the code, public or not.) Carl Mercier wrote: you can't come back to C# because you forgot its syntax! You'd then be on the VB.NET side forever No way!! I can always relearned it! ;P -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
Luis Alonso Ramos wrote: I was just asking for some aspects of the language I will miss (I can think of XML comments -- I usually use them a lot to get a documentation of the code, public or not.) There is a Visual Studio plug-in that will add XML comments support for VB.Net. You can find it here. http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=112b5449-f702-46e2-87fa-86bdf39a17dd[^]
-
Luis Alonso Ramos wrote: I was just asking for some aspects of the language I will miss (I can think of XML comments -- I usually use them a lot to get a documentation of the code, public or not.) There is a Visual Studio plug-in that will add XML comments support for VB.Net. You can find it here. http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=112b5449-f702-46e2-87fa-86bdf39a17dd[^]
Thanks! Looks good, but I'll take a more detailed look at it. -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
-
Giancarlo Aguilera wrote: Option Strict On If I remember correctly, that makes me declare all variables prior to using them, doesn't it? Any other things it does? Giancarlo Aguilera wrote: you may or may not want to treat compiler warnings as errors I always do. Giancarlo Aguilera wrote: VB is the easiest language in the world so don't even worry about it. Actually I'm not worried. I've used Visual Basic before, so I know the syntax. I just expect a few days of again getting used to it... like putting semicolons after statements, for example. :) -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
You will need to cast your variable to the correct type and forget about late-binding, wich is a good thing. :) My Blog
-
You will need to cast your variable to the correct type and forget about late-binding, wich is a good thing. :) My Blog
And how do I cast in VB.NET? Visual Basic had
CBool
,CInt
,CStr
and so on. Is it the same in VB.NET? Yes, you could consider this a programming question... and so what? ;P -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
-
And how do I cast in VB.NET? Visual Basic had
CBool
,CInt
,CStr
and so on. Is it the same in VB.NET? Yes, you could consider this a programming question... and so what? ;P -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
Luis Alonso Ramos wrote: Yes, you could consider this a programming question... and so what? Nah, it's only pseudoprogramming question :P David Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy -
And how do I cast in VB.NET? Visual Basic had
CBool
,CInt
,CStr
and so on. Is it the same in VB.NET? Yes, you could consider this a programming question... and so what? ;P -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
You can use CBool, CInt and so on, but I think they were added for compatibility with VB6 only. The real way to do it would be: CType(x, Integer) (casts x to an integer) or DirectCast(o, Guid) (Direct Cast is pretty much used for unboxing. For example, you have a GUID stored in an Object, you could cast it to a Guid using DirectCast. DirectCast will NOT convert types. You cannot DirectCast an Integer into a Double, for example). DirectCast is faster than CType so whenever possible, use it.
-
You can use CBool, CInt and so on, but I think they were added for compatibility with VB6 only. The real way to do it would be: CType(x, Integer) (casts x to an integer) or DirectCast(o, Guid) (Direct Cast is pretty much used for unboxing. For example, you have a GUID stored in an Object, you could cast it to a Guid using DirectCast. DirectCast will NOT convert types. You cannot DirectCast an Integer into a Double, for example). DirectCast is faster than CType so whenever possible, use it.
Or Integer.Parse(variable), Boolean.Parse(variable). :) My Blog
-
Last week I got a project with one of the offices in the local goverment (we had been negotiating for about two months). Today I met with the systems office of the government, and he said that he had read my proposal and that he liked very much, but that he wanted me to do it in VB.NET instead of C#, and using Oracle as a database instead of my proposed SQL Server. It's an ASP.NET application that won't have a lot of traffic, so I was planning on using MSDE. The database choice is OK because all their databases run on Oracle, and they already have scheduled backups and maintaince. I'm fine with it. And the reason for using VB.NET instead of C# is because all his people (who are supposed to maintain my app in the future) use it, and most don't know C#. I still tried to persuade him, but finally I agreed. I've never used VB.NET, so, will I have any troubles? I've used QuickBasic and Visual Basic in the past, but I've since got used to C#. Other that fighthing with the syntax at the beginning, are there any features from C# I will miss? Or is there any possibility that I'll like it and never return to C#? :omg: -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
I faced a similar situation a while back and you might find it very helpful at first to have on hand a good decompiler like Anakrino http://www.saurik.com/net/exemplar/[^] Write the tricky bits in c#, then decompile the assembly back to vb.net code to see what the differences are. It's extremely useful that way. Secondly there is a nice cheat sheet here: http://www.dnzone.com/ShowDetail.asp?NewsId=356[^] Illustrating language syntax differences between c# and vb.net, good as a reference.
"In our civilization, and under our republican form of government, intelligence is so highly honored that it is rewarded by exemption from the cares of office." - Ambrose Bierce
-
I faced a similar situation a while back and you might find it very helpful at first to have on hand a good decompiler like Anakrino http://www.saurik.com/net/exemplar/[^] Write the tricky bits in c#, then decompile the assembly back to vb.net code to see what the differences are. It's extremely useful that way. Secondly there is a nice cheat sheet here: http://www.dnzone.com/ShowDetail.asp?NewsId=356[^] Illustrating language syntax differences between c# and vb.net, good as a reference.
"In our civilization, and under our republican form of government, intelligence is so highly honored that it is rewarded by exemption from the cares of office." - Ambrose Bierce
-
I faced a similar situation a while back and you might find it very helpful at first to have on hand a good decompiler like Anakrino http://www.saurik.com/net/exemplar/[^] Write the tricky bits in c#, then decompile the assembly back to vb.net code to see what the differences are. It's extremely useful that way. Secondly there is a nice cheat sheet here: http://www.dnzone.com/ShowDetail.asp?NewsId=356[^] Illustrating language syntax differences between c# and vb.net, good as a reference.
"In our civilization, and under our republican form of government, intelligence is so highly honored that it is rewarded by exemption from the cares of office." - Ambrose Bierce
John Cardinal wrote: _Secondly there is a nice cheat sheet here: http://www.dnzone.com/ShowDetail.asp?NewsId=356\[^\]_ I took a quick look at that one, and it seems very complete. I'll have to print it to keep it handy, since there are several syntax differences I didn't know about. Thanks! -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
-
I use Refelector almost daily, it's really good! So Anakrino is in no way better? I just looked at their web page and it's no precisely beautiful. -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
-
You can use CBool, CInt and so on, but I think they were added for compatibility with VB6 only. The real way to do it would be: CType(x, Integer) (casts x to an integer) or DirectCast(o, Guid) (Direct Cast is pretty much used for unboxing. For example, you have a GUID stored in an Object, you could cast it to a Guid using DirectCast. DirectCast will NOT convert types. You cannot DirectCast an Integer into a Double, for example). DirectCast is faster than CType so whenever possible, use it.
-
I use Refelector almost daily, it's really good! So Anakrino is in no way better? I just looked at their web page and it's no precisely beautiful. -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
No new Anakrino version was released since 2002, only a configuration fix to make the old version working on .NET 1.1. It crashes whenever it encounters something that isn't IL code from the Microsoft compilers. Last time I checked, it even crashed when decompiling a method that contained nothing special except an unicode char literal! I does not highlight the decompiled code and has no code navigation. I used Anakrino first because I didn't know Reflector, but I never looked back to Anakrino after trying Reflector.