3

Though I have worked with Visual Basic in the past (VB 4, 5, and 6), ever since the .NET framework was first released I have been working in C#. For an upcoming project I am being asked to work in VB.NET so I am trying to come up to speed with VB.NET. Can anyone recommend any resources (books, articles, etc ..) targeted towards C# developers who are looking to quickly become familiar with VB.NET?

EDIT: I feel I should emphasize, due to certain comments, that I am not trying to compare the various worth of each language (C# vs. VB.NET). Such a comparison wold be subjective in so many ways. Rather, I am saying I myself am not that versed in VB.NET and am looking for resources that would enable me to learn VB.NET considering my experience is with C#.

webworm
  • 10,587
  • 33
  • 120
  • 217
  • 1
    The best resource I can recommend is a clue-by-four. You'll be needing it, trust me. – cdhowie Dec 17 '10 at 21:58
  • 6
    @cdhowie I don't see how that comment helps improve anybody's knowledge. – Michael Wheeler Dec 17 '10 at 22:04
  • 1
    Here's one nice thing you'll find: In recent versions of VB .NET, if you accidentally end a line with a semicolon, the editor deletes it for you. – Ryan Lundy Dec 17 '10 at 22:15
  • @Michael: It's been my personal experience that VB.NET developers are not as mature in their software development skill set as C# developers. (This is not true in every case, of course, but as a generality it's been accurate -- again, in my experience.) So the knowledge I'm trying to convey is that one of the things he will likely have to deal with in a VB.NET environment is programmers with much less skill than himself. Preparing himself mentally for that might be just as important as brushing up on VB.NET syntax. – cdhowie Dec 17 '10 at 22:47
  • @cdhowie: Your first comment was arrogant and not helpful at all. Such comments tend to diminish the value and credibility of other comments you might have. – webworm Dec 18 '10 at 02:39
  • @webworm: It was intended as humor with a nugget of truth. Many developers I've talked to about the issue I was raising will chuckle when I say something similar, indicating that their experience coincides with mine. Others will get riled up. If you are in the latter camp, please understand that no malice was intended. – cdhowie Dec 18 '10 at 03:00

7 Answers7

11

Never, ever forget this when you're doing boolean logic:

AndAlso instead of And

OrElse instead of Or

overslacked
  • 4,127
  • 24
  • 28
  • I agree in general, but there might be some cases when this isn't true, so I'd suggest that the OP reads this question http://stackoverflow.com/questions/55013/should-i-always-use-the-andalso-and-orelse-operators for more information about this answer. – Hans Olsson Dec 17 '10 at 23:17
  • 2
    I just know that coming from c++ I was dumbstruck by the AndAlso/OrElse requirement to short-circuit. I think it's completely rational to expect And and Or to behave as && and || do, which can quickly get you in trouble. – overslacked Dec 18 '10 at 00:00
  • My take on `And` and `Or` is that they're legacy baggage from the pre-.NET days. Since there's apparently still a lot of confusion over the difference, I'd say avoiding them is good general advice. If you actually need to make sure the "B" part of your expression happens, execute it separately and store its result in a variable. Nobody will be confused by that. – John M Gant Dec 21 '10 at 20:05
4

Here is a link that compares the two languages: http://www.harding.edu/fmccown/vbnet_csharp_comparison.html

In truth with .Net 4.0 they are pretty much the same. The syntax is different (obviously), but their functionality is nearly identical. This is now by design, Microsoft plans on co-evolving them from now on, so new features will be added to both.

kemiller2002
  • 113,795
  • 27
  • 197
  • 251
4

Just dive in. Seriously, that is the best way to learn. Functionally, they are mostly the same these days.

For me, the major differences are

  • lack of support for iterators (yield return) in VB.Net (coming in the next version)
  • XML literals in VB.Net are not available in C#. As a C# developer, many times I prefer VB when working with XML these days...
  • linq query syntax behaves differently in VB (richer at first sight in VB, but much more consistent in C#)

Other than that, it's mostly just syntax

Oh, and don't forget to put Option Strict and Option Infer on... If you need dynamic, you can 'sort of' get the same by turning off Option Strict (I recommend doing this at the file level).

jeroenh
  • 26,362
  • 10
  • 73
  • 104
2

I work with both, if you know C# and know VB6 syntax, it'll be easy to pick up (I started with C# since I have more of a C++ background, but I also had some VB6 so it was very easy to start working on VB.Net as well).

There's a few things you'll have to look up every now and then but as Kevin says, they're more or less the same language. And anyway, the languages themselves aren't that big so aren't very difficult to learn, it's learning the .Net Framework that takes a lot of time, so you know what's already written and where to find it, and your knowledge of that transfers across.

Hans Olsson
  • 54,199
  • 15
  • 94
  • 116
1

go to msdn Visual Basic Developer Ceneter , you'll find tons of information there

http://msdn.microsoft.com/en-us/vbasic/default

here is a learning guide

http://searchwindevelopment.techtarget.com/tutorial/Choosing-VBNET-or-C-Learning-Guide

Saif al Harthi
  • 2,948
  • 1
  • 21
  • 26
1

Google is good for checking syntax differences (search "C# keyword equivalent in vb.net"). MSDN is good about having code examples in both VB and C# too.

This online conversion tool can often be helpful too.

NoAlias
  • 9,218
  • 2
  • 27
  • 46
0

Besides the short circuit operators, one thing that can trip you up is not initializing your variables. It seems like you don't have to, but if you are in a loop you actually do have to.

dwidel
  • 1,264
  • 1
  • 12
  • 22