r/visualbasic • • Nov 03 '14

Is Visual Basic something a total beginner can learn?

Hi all. My husband, who is not a programmer but has some programming experience, is thinking about learning Visual Basic because of a potential new job opportunity. I am an absolute beginner when it comes to programming but I thought it might be more fun to learn together. Is this a good idea? Are there any tutorials you would recommend? Thank you!

6 Upvotes

19 comments sorted by

4

u/hdsrob Nov 03 '14

Absolutely...

I'm completely self taught, have been programing professionally for over a dozen years, write in a handful of languages, was a senior level dev at my last job, and have owned my own company for about 6 years.

Getting the basics is easy enough, getting a really deep understanding will require a lot of dedication, and a never ending process of learning, but it can be a really fun hobby.

Like melot2K1 said, you really want to focus on fundamentals of programing, and not specifically VB, once you get past the beginning stages. Understanding this larger picture allows you to see beyond the constraints of one language, and opens up a lot of other opportunities.

The link below is a great place to start:

http://channel9.msdn.com/Series/Visual-Basic-Fundamentals-for-Absolute-Beginners

1

u/ThinkingViolet Nov 03 '14

Thank you very much! Your reply was quite encouraging!

3

u/no1name Nov 03 '14 edited Nov 04 '14

VB.net is a great learning program, its an easy step to C# which is a fully commercial language. But make sure you are learning VB.net and not just VB.

VB is too antiquated and will teach you an outdated framework that you will just need to 'unlearn' later.

1

u/ThinkingViolet Nov 03 '14

Thanks for this tip!

1

u/CalvinR VB.Net Master Nov 04 '14

Vb.net is a commercially viable language. It is essentially the exact same language as c# with just a few differences in functionality.

1

u/no1name Nov 04 '14

I agree, I worded it that way as there are far more jobs in C# than VB.net

1

u/krad0n Nov 04 '14

My job is in VB and I honestly wish it was c# at times. C# feels more programmy.

1

u/ComicOzzy Nov 04 '14

It does, but it can also just be a pain in the ass to "get shit done". I'm forcing myself to learn C# because I feel like it's time to wear big boy pants, but it's amazing how much time I've wasted just trying to work out a few things VB just handles automagically. Most of the time I end up finding out I just needed to do something differently (the C# way), but when it comes to reading nullable fields from a database, I just want my VB back.

1

u/CalvinR VB.Net Master Nov 04 '14

Can't you use null coalescing operator in C# for this something like

outputvalue = ReadDBField() ?? DefaultValue;

I find it much nicer then using something like this

outputvalue = If(ReadDBField(),ReadDBField(),DefaultValue)

Or is that an example of what you are trying to do.

What I find very annoying with VB is the way they handle generics and array syntax.

Here is a couple of examples

C#
Foo[0] 
VB
Foo(0)

You can tell that the above is alookup in a collection in C# without having to look at the type of foo

C#
Foo[0]("Bar")
VB
Foo(0)("Bar)

If I showed you the vb code you'd not be able to tell me if it's a collection containing a collection, a collection containing a function, a function that returns a function. With C# it's pretty apparent that it's a collection that returns a method call.

And in this case

C#
Foo<List<bar>>(x => x.ToString())[0]
VB
Foo(of List(of bar))(Function(x) x.ToString())(0)

I personally much prefer the C# to the vb but really that's a personal preference I have an easier time visually parsing the C# to the vb.

Now the few things that I do like in VB but that haven't really used at all is XML literals, I'm more likely to read an xml from a file then type it directly in my code, I've only used it once in my ten years of vb development but it was handy.

1

u/ComicOzzy Nov 04 '14 edited Nov 04 '14

Can't you use null coalescing operator in C# for this something like

outputvalue = ReadDBField() ?? DefaultValue;

I find it much nicer then using something like this

outputvalue = If(ReadDBField(),ReadDBField(),DefaultValue)

I was using:

SqlDateTime? derp = reader.IsDBNull(ordDerp) ? (SqlDateTime?)null : reader.GetSqlDateTime(ordDerp);

I've never seen the null coalescing operator before. What I can't figure out is how to use it like this:

SqlDateTime? derp = reader.GetSqlDateTime(ordDerp) ?? (SqlDateTime?)null;

I get this error message:

Left operand of the '??' operator should be of reference or nullable type

If I could figure out how to return reader.GetSqlDateTime as nullable, I would have no problems to begin with. What might I be doing wrong, or what could I do differently?

  • ordDerp being the column ordinal for the Derp field, of course.

1

u/CalvinR VB.Net Master Nov 04 '14

Yeah so obviously I didn't pick a good operator I think the ternary operator is a good fit here I'd personally shove it in an extension method something like

Public static class extensions {
public static SqlDateTime? ToNullable(this SqlDateTime dt )
{
    return (DT.IsNull)?(SqlDateTime?)null:dt:;
}
}

And call it like

var derp = reader.GetDateTime(ordDerp).ToNullable();

Pardon any mistakes I did this on my phone on the bus home.

1

u/CalvinR VB.Net Master Nov 04 '14

Or something like

public static T? ToNullable<T>( this SqlReader r, string name){
return r.IsDbNull(name)?(T?)null:r.GetFieldValue<T>(name);
}

var deep = SqlReader.ToNullable<SqlDateTime>(ordDerp);

For some reason reddit news.pro is not showing the angle brackets, that should be a generic method of type T and calling it with type SqlDateTime

1

u/ComicOzzy Nov 04 '14

I'll have to play with this. It would be really nice to not have to use the ternary method every single time. Thanks!

1

u/CalvinR VB.Net Master Nov 04 '14

Remember to put anything you want to be an extension method to put in static class

2

u/merlot2K1 Nov 03 '14

Any high-language can be taught to a beginner. What's most important is to learn the basic concepts of programming, such as declarations, variables, functions, conditionals, etc.. I feel like that is something which is better learned in the class room. Once you get the basics down, learning a new language via books or online tutorials is easier and makes more sense.

Maybe there's a an "Intro to Programming" class at a local college you both can take?

1

u/ThinkingViolet Nov 03 '14

Great idea - there are several nearby opportunities for continuing education. I'll see what is available. He probably doesn't need an intro class, but I certainly do!

2

u/[deleted] Nov 03 '14

Never had programmed before, bought this book:

Sams Teach Yourself Visual Basic 2012 in 24 Hours

I went through the book and fought through all the exercises. I then started on a project I needed to do at my job. I was amazed at how the code flowed out. It was literally like a scene out of the Karate Kid.

1

u/ThinkingViolet Nov 03 '14

Thank you! Glad you had such a good experience - that sounds awesome!

0

u/[deleted] Nov 04 '14

[deleted]