Learning VB.NET??
-
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.