The first few posts are all going to come in one go, as I just started proper Computing lessons last Tuesday, so I had to learn all the beginning lessons in pretty much one go. I followed the classwork in the first lesson and then on Wednesday I did three hours in the Computing workshop.
Okay, so onto lesson one. Essentially this was just a run down of key terms and the basics of programming.
Visual Basic Lesson 1:
So, I guess I should start with variables. But before that you need to understand RAM. RAM stands for Random Access Memory. It is a temporary form of memory, which has different sections or locations in which data can be stored. ROM is Read Only Memory and that is a more permanent form of memory.A variable is a location in RAM memory where data is stored and ever-changing, it is usually given a name. The name which you give a variable is called an identifier which is probably because it is how you identify which variable is which, but that's just a shot in the dark for me.
With identifiers you need to make sure that your identifiers are self-documenting, which basically means that they need to have sensible names, which you will understand when you or another programmer comes to visit your program at a later date.
When programming, you always have to declare the variables and that is no exception when using Visual Basic (hereafter known as VB). A simple "equation" for a variable declaration would be:
Dim (Identifier) As (Data Type)
e.g Dim marks1 As Integer
But wait! What does "dim" mean? And what is a data type?! Well dim is short for dimension and it is a way in which to define a variable.
And data types? Well, different data types are used for different types of data.
Common data type examples would be:
Integer - used to store whole numbers. Data can be used in calculations.
Single - used to hold decimal numbers. Data can be used in calculations.
String - used to hold letters and numbers. Data cannot be used in calculations.
Date - used to hold date and time information.
Char - used to store one single letter. VB does NOT used this data type.
Booelean - can only hold one of two values. e.g. Yes and no or true and false.
Also when coding there are other components. For example there are statements, two key types of statements are assignment statements and selection statements (which will be covered in another lesson) these statements allow you to use the variables you have declared in your code in order to carry out a particular function.
An example of an assignment statement would be:
name = InputBox("What is your name?")
Remember, your code should be self-documenting, as well as your identifiers. Therefore your programs should be well-structured, with comments and they should be indented and clearly laid out. No goto statements should be used!
After I got all that round my head it was time to start programming.
I did a basic program, which I call the "Birthday Program", it was fairly simple and easy and I was quickly able to add bits to it.
And that's essentially the end of lesson 1. Hope I haven't forgotten anything, but as I said, several lessons were squashed into one.
See ya next time :).
No comments:
Post a Comment