VBA Programming 101: Lecture 01

FarRockBF·5/22/2015, 12:37:41 AM·5 votes·1,063 views

Before I begin Excel or VBA there are three terms you need to be very comfortable with: Strings, variables, and functions. So without further ado,

STRING: A string is more than one character in a row. Example of strings: 18463 ADJOGKN FEH355#%^

Q) How does a computer program know that what you are entering is a STRING and not some other data type (such as a function or variable)? A) Almost all programming languages require quotes around a string. This tells the program not to do any fancy shtick on it, just read it as just a jumble of characters.

So, if a program sees: **Hello **- it is going to try to figure out how to execute the program Hello. But if you put quotes around it: "Hello" the program will now know that this is just a dumb string you want it to accept. It will not attempt to do any fancy magic with it.

Variable: A variable is a character (usually a letter) that can change its meaning. The word variable comes from two words: VARY + ABLE, so it is able to change.

An example:

Let's say X is equal to 7. This statement is true: "There are X days in a week".

Now if we change X and say X = 9, the statement "There are X days in a week" is FALSE. Same statement, but what you reassign the variable to a different meaning, it means something entirely different.

**Function: **A machine that accepts an input, does some predetermined procedure to the input value, and returns the new value.

An example:

Let's call our function Bob. Function Bob takes anything that is put into it and DOUBLES IT. So what would happen if we put $3 into Bob? Let's find out!

Bob($3) = $6

"( )" is where you place the input usually, and after the "=" is where your output value will come. Let's look at another:

Bob("Cat") = "Cat Cat"

So here we put in a string and Bob doubled our input as expected.

Thanks for tuning in guys, and please vote this thread up if you enjoyed this read. It takes quite a bit of time to put together but if I see people are enjoying them I will continue posting these lectures.

FarRock

9 Comments

Battleforge4Life5/22/2015, 1:33:59 PM2 votes

Ty for this

disregardable5/22/2015, 12:49:37 AM1 votes

But why?

FarRockBF5/22/2015, 12:40:41 PM1 votes

Bump for morning readers.

FarRockBF5/22/2015, 7:31:05 PM1 votes

One last try, otherwise, I'll just dump this effort.

Drunk Rummate5/26/2015, 7:20:30 PM1 votes

Posting in here for bookmark purposes. Thanks OP :]

Sorry I'm a bit slow to respond, got a busy schedule. But I for one appreciate your work..!