VB vs C#?

Add-in Express™ Support Service
That's what is more important than anything else

VB vs C#?
Jeremy McClanathan

Posts: 19
Joined: 2017-02-09
I am wondering if any of the programmers at ADX have any experience and/or opinion regarding whether or not there is a significant advantage to programming in VB.net or C#? I have been reading through a lot of content on the web with mixed opinions one way or the other. So far, it sounds like C# has a much larger community and examples to learn from, which would be a big advantage if true. Visual Studio and VB.net or C# are new to me, but I am very comfortable in VBA, so VB.net certainly feels more familiar. Just wondering if you had any experience/opinion one way or the other.
Posted 23 Feb, 2017 02:07:42 Top
Andrei Smolin

Add-in Express team

Posts: 15497
Joined: 2006-05-11

I'm an example of a programmer who switched from VBA and then VB.NET to C#.

VBA pushes you to save the typing time rather than the debugging time. This sort of laziness is quite harmless and it's easy to go over this barrier.

Because VBA hides many things from you, it doesn't push you to better understanding of what you do. As a result you just use "tricks" (they mostly work). In VB.NET, you need to use different "tricks"; you looks at them as "this requires time". This is true of course but writing COM add-ins in .NET does require better understanding of what you do. For me, C# (compared with VB.NET) seemed to be "another world" programming: I saw methods that you don't understood, complex constructs instead of simple ones (consider late binding).

Regarding late binding, in VB.NET they have Option Strict Off by default (this comes from VBA). Set this option to On and you won't find any serious difference between VB.NET and C#. Still, since most code samples are given in C#, a VB.NET developer should understand the following C# constructs:
- declarations
- loops
- the using keyword
- the System.Type.InvokeMember() method (it' late binding)

It is minimum, of course.

You may find my blog at https://www.add-in-express.com/creating-addins-blog/2010/08/13/porting-vb6-addin-to-net/ useful.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 Feb, 2017 02:38:43 Top
Marcus Datascout

Posts: 33
Joined: 2015-04-12
Hi Jeremy,

I'm also a developer that first learned VBA, then C# and then VB.Net.
I started VBA in Excel 5, then started C# 7 years ago and VB.Net 4 years ago. I use all 3 languages regularly.

So to your questions:

-- "significant advantage to programming in VB.net or C#"

This may be partially determined by your objectives and what you consider to be a "significant advantage".

As I working in banking & finance, I initially chose C# over VB.Net because there was far more demand for C# in this industry and - quite frankly - that's where the money was.
In many industries C# jobs pay more (and is more respected) than VB.Net (which is kind of odd because at the end of the day they both compile to basically the same IL code).
I manly use C# for server based and ETL projects.
However for my own ADX projects I use VB.Net as I feel VB.Net "talks nicer" to the application object hierarchy (like VBA) than C# does.

I don't personally feel that one language is 'better' than the other - they're different. Ignoring the curly braces, I like the succinctness of C#, yet I much prefer the flexibility of VB.Net's "Select Case" compared against C#'s "Switch" statement.

-- "C# has a much larger community and examples to learn from"

Given the sheer volume of information for both languages, I consider this to be a non-issue.
There's such a wealth of books, blog-posts, You-Tube Videos and StackOverLoad questions covering both languages, that this alone shouldn't be a deciding factor for you.

Remember, also that you're not having to make a choice of one *or* the other. Both languages use the *same* class library framework.
Once you've learnt one language in conjunction with the .Net framework class libraries, you're a long way into learning the other language.

All the best -
Posted 23 Feb, 2017 04:33:20 Top

Posts: 194
Joined: 2015-08-13
Hi Jeremy,

I am an example of a programmer who switched from VBA to C#. My decision was mainly based on several criteria:
A) Community support, code snippets, tutorials, etc floating around
B) Is there a way to code for Linux?
C) How different from Java
D) How hard to achieve a professional level?
E) Money

A) It is of course true what Marcus says, there is an impressive amount of information available for both languages, but if it comes to tricky questions (e.g. implementing a full COM interface, reading a NTFS journal, dealing with ActiveDirectory, etc) you would rather find a C# snippet than one in VB.net.
B) Yes, there is a spin-off called Mono, half way there.
C) Not so much, half way there.
D) Depends on how tough you are. For some situations it might be helpful to create a mantra like, 'I can change my code more often than the compiler can throw exeptions towards me' ;-)
E) As Marcus perfectly right states, at the end of the day both languages are using the same framework, but for some odd reason you are getting paid better when coding C#.

I have never regretted it doing it this way. As a result I have learned reading/coding Vb.net just from not forgetting VBA (still loving it!) and combining it with the C# knowledge.

I am confident, you find your own path.
Kind regards
Posted 23 Feb, 2017 09:54:29 Top