Ok. In this tutorial we will be fiddling around with a text file. Opening and manipulating files is a key concept for editing. You will also learn a few more programming basics.
First of all, Colin mentioned a variable in his tutorial, but I just want to go in more detail.
A variable is a value that
changes. You can fiddle around with your hearts content with a variable. For example (feel free to try this):
Code:
Dim strMsg as String = "Hello John!"
Message.Show(strMsg)
What does it all mean? The "dim" is used to tell Visual Basic that we are
declaring a variable. the "msg" is the name you give to the variable. This has to contain letters (a-z), numbers or an underscore. For example these are all good variables:
Code:
myMsg
Button12345
UserAge2
Swing_amount
And these are both bad variables (compiler will give you a nasty sounding error if you try these:
Code:
folder/ (not allowed slash)
23marks (can't start with number)
The next part is the name of the variable ("strMsg"). It is generally better to have a descriptive name rather than something you don't understand (you won't have to keep on checking what it is). Colin mentioned Visual Basic coding conventions, the point of these is that you don't forget what type the variable (see next section). This helps you not do do things on text you're supposed to do on numbers. So "strMsg" tells us instantly that the variable
is of type String, and it stores a message.
Right the type ("... as String"). You don't have to have a type, but it is a good thing. There are thousands of different types , but I'll jsut mention a few common ones.
A String is a piece of text. That simple. You can tell Visual Basic a value is a string by putting speech marks round it like:
An Integer is a whole number, like 2 or -37 (can be minus, just no decimal places like 0.2 or 3.4). Integer values can store anything from -2,147,483,648 to 2,147,483,647.
And finally, you can assign a value to the variable ("= "Hello John"). You can do this on the same line as the rest of the declaration, or you can do it on a different line using:
More from me later, I have to go. Digest that.