how to learn visual basic?

Associate
Joined
12 Jul 2010
Posts
334
Hey there

Has anyone got a good book or website for learning 'good' VB code?

i can code in C & C# & planning on learning C++ in the summer however the job I’ve taken for the summer for extra cash practically requires me to know VB but I know VB is taught to high school students thus most books/sources are slow & the code isn't really good in practise. i.e. VB for dummies

So I'm wondering if anyone can suggest a book/online source for more intellectual experienced programmers?


Thanks
 
Essentially VB = C#.

They are so similar there really is little in it, if you look on MSDN information pages they will provide you with VB and C# snippets of methods etc. There are even loads of VB -> C# and C# -> VB generator web pages they are that similar.
 
http://www.homeandlearn.co.uk/net/vbnet.html

Try that, I've never read a book. 100% self taught.

The great thing about the internet is you can ask how to do pretty much everything and you'll find example code very quickly.

Essentially VB = C#.

They are so similar there really is little in it, if you look on MSDN information pages they will provide you with VB and C# snippets of methods etc. There are even loads of VB -> C# and C# -> VB generator web pages they are that similar.

This is correct but it won't be long before someone who uses C# will tell how much better it is. Up until VB.NET (<= VB6) that was true, but now there is no advantage to using in either, just what you prefer. To me VB is a lot more logical to read than C#, but that is highly subjective of course.
 
Last edited:
http://www.homeandlearn.co.uk/net/vbnet.html

Try that, I've never read a book. 100% self taught.

The great thing about the internet is you can ask how to do pretty much everything and you'll find example code very quickly.



This is correct but it won't be long before someone who uses C# will tell how much better it is. Up until VB.NET (<= VB6) that was true, but now there is no advantage to using in either, just what you prefer. To me VB is a lot more logical to read than C#, but that is highly subjective of course.

Indeed they're functionality equivalent, most languages are.

But to experienced developers, VB is freaking ugly. A very verbose language.
 
Indeed they're functionality equivalent, most languages are.

But to experienced developers, VB is freaking ugly. A very verbose language.

I knew it wouldn't take too long before this kind of pretentious guff comes out.

Most 'experienced developers' will use C# because most of their career C# was a better language (compared to VB6 and below) in terms of flexibility and performance so they have spent years reading, absorbing and getting used to reading that language.

I think German sounds 'freaky ugly' but someone who speaks it would naturally disagree.

As I said it's about what you prefer, now the two language are functionality identical it's pointless debating which one looks better, just be happy there is a choice.

And any developer that cares more about his experience over the end users probably isn't writing very good programmes anyway.
 
OP, here's an example of doing the same thing in C# and VB. You can decide which one seems easier to read FOR YOU (although at this point they'll both seem like gobblegook)..

Creating and filling an ArrayList (a list of items stored in the memory for use later BASICally...see what I did there)

C# (// denotes a note/description and not actual code)
using System;
using System.Collections;
public class SamplesArrayList {

public static void Main() {

// Creates and initializes a new ArrayList.
ArrayList myAL = new ArrayList();
myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");

// Displays the properties and values of the ArrayList.
Console.WriteLine( "myAL" );
Console.WriteLine( " Count: {0}", myAL.Count );
Console.WriteLine( " Capacity: {0}", myAL.Capacity );
Console.Write( " Values:" );
PrintValues( myAL );
}

public static void PrintValues( IEnumerable myList ) {
foreach ( Object obj in myList )
Console.Write( " {0}", obj );
Console.WriteLine();
}

}

VB (' denotes a note/description and not actual code)

Imports System
Imports System.Collections
Imports Microsoft.VisualBasic

Public Class SamplesArrayList

Public Shared Sub Main()

' Creates and initializes a new ArrayList.
Dim myAL As New ArrayList()
myAL.Add("Hello")
myAL.Add("World")
myAL.Add("!")

' Displays the properties and values of the ArrayList.
Console.WriteLine("myAL")
Console.WriteLine(" Count: {0}", myAL.Count)
Console.WriteLine(" Capacity: {0}", myAL.Capacity)
Console.Write(" Values:")
PrintValues(myAL)
End Sub

Public Shared Sub PrintValues(myList As IEnumerable)
Dim obj As [Object]
For Each obj In myList
Console.Write(" {0}", obj)
Next obj
Console.WriteLine()
End Sub 'PrintValues

End Class

They aint a million miles apart (so I dunno where the 'freaking ugly' comment comes from, I suspect the last time UK-AL05 saw visual basic code it was the 'old' <VB6 version which was slightly more archaic than the newer VB.NET code).

For me personally, having to end every line with ; and bracket ({) everything off as you have to do in C# seems like more effort than is needed, but I re-iterate that is my subjective opinion.
 
Last edited:
ok... i do stress that it's not my choice :/ i would love to work in C# but it'll be much more beneficial for the employee for me to programme it under VB due to certain circumstances.

i personally like C# more than VB due to A) VB is line sensitive & B) VB is much more of an wordy language. @ estebanrey the brackets & ; to me gives the programme structure making it much easier to read when you're code gets larger.


In my degree we were taught C first but next year's doing our year will be taught C++. i personally dislike C as a language [not it's type] thus why i'm learning C++ in the summer. imo C#>java, C++>C.
 
Last edited:
A) VB is line sensitive

True but you can just use " _" to carry on with the same line of code on another line. That's less effort than having to end every line with ; IMO

B) VB is much more of an wordy language.

It used to be, now not really. Look at the examples I gave, they contain pretty much the same amount of words.

@ estebanrey the brackets & ; to me gives the programme structure making it much easier to read when you're code gets larger.

Fair comment, but I'd say it depends on what your used to. I'm used to VB so can read it easily. If you are used to a language then it's always going to be easy to read.

I struggle reading large amounts of C# because you have to keep working out which is the start bracket for every close bracket which I don't find something that comes naturally to me.

But it sounds like you are versed in C# so I can understand why you find that easier to read than VB.

In my degree we were taught C first but next year's doing our year will be taught C++. i personally dislike C as a language [not it's type] thus why i'm learning C++ in the summer. imo C#>java, C++>C.

Sounds like you'll be a programming genius before long, I wish I could write in a variety of languages. Good luck my friend and I get discount on any programmes you produce OK? :cool:
 
OP, here's an example of doing the same thing in C# and VB. You can decide which one seems easier to read FOR YOU (although at this point they'll both seem like gobblegook)..

Creating and filling an ArrayList (a list of items stored in the memory for use later BASICally...see what I did there)

C# (// denotes a note/description and not actual code)


VB (' denotes a note/description and not actual code)



They aint a million miles apart (so I dunno where the 'freaking ugly' comment comes from, I suspect the last time UK-AL05 saw visual basic code it was the 'old' <VB6 version which was slightly more archaic than the newer VB.NET code).

For me personally, having to end every line with ; and bracket ({) everything off as you have to do in C# seems like more effort than is needed, but I re-iterate that is my subjective opinion.

I think misunderstanding my experience. I've been using the .net platform for a long time. I know precisely how VB.net is implemented, they're both on the .net virtual machine and thus can use the same features and libraries. In fact i've implemented my own language on the .net platform.

However VB.net is very verbose(Not a nice feature in languages), the only they reason implemented vb.net is to encourage legacy vb users to move over .net. Microsoft lends most of it's support over to c sharp users.

I agree vb.net can similar, especially with Option Strict On, together with Option Explicit On. But it's still verbose language.

Does vb.net have something simular to the 'using' statement now?

Edit:
Yes it does.
 
Last edited:
However VB.net is very verbose(Not a nice feature in languages), the only they reason implemented vb.net is to encourage legacy vb users to move over .net. Microsoft lends most of it's support over to c sharp users.

I prefer the verboseness though and you cannot objectively claim that a language being verbose is a bad thing as you have above. Nor do I agree that VB.NET was only introduced to entice legacy VB uers to migrate to .NET given VB.NET was essentially a new language that required not much less effort to take on than just learning C# from scratch. In fact legacy VB users complained when it when basic moved to VB.Net because it was so different.

Here's a professional VB & C# user (I'm just a hobbyist) who puts these arguments better than I can...

Why do C# developers look down on VB.NET?


Takeaway: Justin James is surprised that most of the anti-VB.NET talk he hears is from C# developers. He argues that it’s particularly baffling because the language that most resembles VB.NET from a technical standpoint is C#.

As you may remember, last year I moved from VB.NET to C#. This year, it looks like I will be doing a lot of work in VB.NET. Some of the people I told this to acted like I said I was forsaking my family and joining a wacky cult in Nepal or something. If it was coming from Java or Ruby or PHP folks, I could understand — VB.NET is sufficiently different in philosophy and style from those languages for there to be a point of contention — but the people who seem to hate VB.NET the most are C# developers. I just don’t understand.

When I made the move to C#, the final motivator was not a deficiency with VB.NET, it was the fact that I was working on customizing a product that was already written in C#. Re-reading that article from June 2008, even then I had no overwhelmingly good reason to stop using VB.NET; on the whole, it was meeting my needs. Most of the pressure that I was feeling to start using C# was social pressure from other developers. In the .NET world, it feels like VB.NET people are often considered to be less capable or less experienced than C# developers, or that C# is a substantially better language than VB.NET.

Don’t mistake me here; I know where the anti-VB sentiments traditionally come from. The VB family up through VB6, VBA, VBScript, and the other variants is a wretched language on all technical fronts. As far as I can tell, the only good thing about VB was that it was easier to get things done in it than the alternative at the time, which was C++. I always was baffled that VB beat Delphi, which was just as easy to use and much better on a technical level.

But folks, pinning the sins of VB on VB.NET is factually unsupportable. Remember the stink that VB developers made when VB.NET came out? It’s because VB and VB.NET are truly two entirely different languages that happen to share enough common syntax to be visually identical at a casual glance. I am not going to enumerate all of the differences between VB and VB.NET here; it would take a book to list all the differences. It is safe to say that, other than syntactic similarities, VB and VB.NET are different languages.

In fact, the language that most resembles VB.NET from a technical (not a syntactic) standpoint is C#. Thanks to the .NET Framework, VB.NET and C# have identical libraries; this means that anything you can do in one language can be done in the other in terms of library calls. At a functionality level, C# offers a few things that VB.NET does not (multi-line lambdas are a big one), and VB.NET has some features that C# does not (like optional and named parameters, which are important). In .NET 4.0 (which is coming out next year, if not sooner), most of these gaps will be closed. The typical business developer will probably never use something in C# that is not in VB.NET, or vice versa.

At the end of the day, the practical differences between VB.NET and C# are items that fall under the category of personal opinion. There is nothing wrong with that; some developers prefer a more verbose language like VB.NET, while some like one that is a bit more terse. There are pros and cons to each viewpoint. But to act like VB.NET is some pariah language and C# is the bee’s knees… that just does not make sense.

J.Ja
 
Last edited:
I found that some of the more complicated stuff starts to become difficult to read in VB.NET, unfortunately I don't have an example right now though :p.

Personally I much prefer C# because I find it a lot easier to read, I seem to find it a lot easier to pick out braces {} over words, which seems to be the opposite to how estebanrey sees things. So really each to their own I guess :D. Also if you were just starting out I would always recommend C# over VB purely because it prepares you better for reading other languages.
 
There is little in it now, to be able to make a definitive argument either way. There are some features that VB.NET has that C# doesn’t and vice versa.

If you understand OO and how to structure an application then the code will look very similar on the surface. The main problem came with the release of .NET and old VB6 developers writing procedural code in a true OO environment. However most developers now understand true OO semantics and can design software
 
Last edited:
OOI can VB.Net do lambda expressions properly yet?

Yes. You can't do multiline and the keywords differ if you want it to return something or not, but they are there in the usual VB wordy-style:

Code:
Dim someFunc as Func(of Integer, Integer) = Function(x) x +1 

Dim someAction as Action(of String) = Sub(x) Console.WriteLine(x)

someAction("1 incremented by 1 is: " & someFunc(1))
 
Back
Top Bottom