Author Topic: VBA some simple questions  (Read 1587 times)

0 Members and 1 Guest are viewing this topic.

JONTHEPOPE

  • Guest
VBA some simple questions
« on: August 08, 2014, 12:21:51 AM »
Why does it take less code to do something with VBA/Active X than with C#?

Can you build a VBA/Active X program with Visual studio?

I thought VBA/Active X was no longer supported or will not be in the future is this right?

« Last Edit: August 08, 2014, 06:55:00 PM by Kerry »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16727
  • Superior Stupidity at its best
Re: VBA some simple questions
« Reply #1 on: August 08, 2014, 06:22:14 PM »
VBA and ActiveX isn't entirely unsupported, but in order to use it on newer installations, you must download the VBA enabler and install it. It no longer installs as part of the base installation.

I guess the simplest answer as to why VBA uses less code than C# is because VBA does a lot of the stuff "under the hood" while C# does not. It is the same reason why C# has less code to do many things than does C or C++, because the .net libraries do much of the "under the hood" stuff that C and C++ does not take advantage of.

To be fair, there really isn't less code involved in the project as a whole, it is just that much of the code has already been written by others, compiled into binaries and imported into the coding environment for you.

At the same time, you should recognize that there are many advantages to using C# or VB.Net where there is less coding involved.

For example:
Code: [Select]
'VBA
'Declare a variable
Dim ThisVar As Integer
'Assign a value to a variable
ThisVar = 1
'Multiply a variable by 2
ThisVar = ThisVar * 2

//C#
//Declare a variable and assign it a value at the same time
int thisVar = 1;
//Multiply a variable by 2
thisVar *= 2;

Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

MickD

  • Gator
  • Posts: 3321
  • (x-in)->[process]->(y-out)
Re: VBA some simple questions
« Reply #2 on: August 08, 2014, 09:58:25 PM »
Depending on what you want to do (how far down the rabbit hole you want to go :) ) you may be better off learning lisp. It will be around a long while yet so your effort wont be wasted.

Vba was/is a scripting alternative to lisp but its popularity stemmed from the ease of creating dialogs and more complex applications. This can be done in lisp as well these days but if you only want to automate some simple routines then lisp is the go, C# can be overkill and and involves a big learning curve for your limited return on effort.
No matter what you want you will find it already written in lisp, there is a huge and very very knowledgeable user base right here at the Swamp.

If you do need to write a more complex app in vba you will soon hit a wall where you wish you had more control, C#/vb.net/ObjectArx will give this to you but you will need to write the boiler plate code that was under the hood in vba yourself but it will do what you need. There is no in between.
 
Be prepared to do a lot of study and practice, write lots of code yourself, read the api doc's and then when/if you really get stuck you can always ask for help. You won't learn anything unless you make mistakes, you gotta do your time if you want to advance your skills. Sure, copy and use snippets to put something together but make sure you understand each of them before you use them as they will bite you later if you don't :)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”