Over the past few months, I have been learning Visual Basic, C# and Unity. Like many teenagers the task at hand was rather daunting, all these different numerical and grammatical terms but eventually it came like second nature however before we start I will fill you in on some back story. I am currently doing my A-Levels, for those who do not live in Britain or do not know what A-Level is, it is the last two years of school, these two years are not compulsory so naturally work is much harder. I have always been fascinated with computers full stop but I have always loved games and I always will love them, they are an irreplaceable part of my life, many may wonder why do I love them so much and there is not a clear answer to that but all I can say is that they bring my friends and I together, we have fun and memories are created. So now my dream is to eventually own a game company with my friends, to bring experiences to others that they too will never forget, I know that, that would make me happy. So here I am now a few months into my computing course and around 8 months into Visual Basic. Today I will be starting to teach all of you some Visual Basic and then in 2014 some C# and Unity 3D.
Before I go any further I want to say that I am no where near fluent, I am still a rookie but I have never seen any tutorials that come from rookie to rookie and that puzzles me because as I learn, you will also be able to learn, everything I post I will make sure to check works. This means though that you should be able to connect more to what I post as after all I will not confuse you with loads of different terms unless I can explain them well to you. So Visual Basic is what we will start with, not only is it the language I am getting taught in but it is nice and easy for beginners as it uses more English than others such as C++, Java or even C#.
To start off you will want to go to this page and download Visual Basic 2010 Express Edition.
Ok so when that is all downloaded and you open the project you should see this screen.
The starting screen is nice and easy in my opinion unlike some other IDE’s. That is your first term of your programming career. IDE stands for Integrated Development Environment, this is the hub of making your code. It allows us to turn our code which is useless for a computer and turn it into useful code for the computer! It also allows us to use helpful tools which will allows us to find errors in our code and it will also show us what the software would look like once it is run.
Next we want to load up a new project, click new project, by default Windows Forms Application should be selected. This is what we will be using to make our software. You can then name your application anything you want but for this tutorial I shall name mine Tutorial 1 – Using A Label. After a few seconds your screen should look like this:
Fear Not! This is perfectly fine and this is what you will see hundreds and hundreds of times again. This is the Bread and Butter Of A WFA (Windows Form Application) This is really why VB is great for beginners, other languages would just have your basic console, No nice designed forms. Ok so now if you look at your form you will see some things you need to get familiar with. Firstly on the left, top sidebar you should see “ToolBox” this toolbox is where you can add many different useful features to your form, for today I want you to navigate to label:
Now double click label and go out of your tool box, do not press the x in the corner though as this will remove the toolbox from the sidebar instead click on the blank space by the side of your form. If you did click off the toolbox then go to the top menu and go right across to the other side where there is a little hammer and spanner, clicking it will add the toolbox to the sidebar.
You can drag the label to where you like and then on the bottom left you should see the Properties menu. In the properties menu scroll up through it till you see “Name” change the name to lblHello. The reason we are calling it this is because in our code we can assign the label properties by referring to it’s name so if we call all labels lbl(Name) by typing in lbl the code will show us all labels and their names but I will show you that later in the tutorial. For now just have the name as lblHello:
Notice in the bottom left hand corner our Name property is now lblHello. So now if we double click the grey form area we should access the code view. In the code view some code will already be present, ignore this code for now, do not delete it but we do not need to no what it does yet.
We now want to write our first ever piece of code so if you click in between the private sub code and end sub we can begin. If we type lbl it will show us a list of features whose name begin with lbl for now we only have one but this is extremely handy for when we have large amounts of features.
Now we need to continue using lblHello. For this you can either type the full lblHello or you can click the option which has appeared to use lblHello if however once clicked it presents you with () after lblHello delete them. So VB makes it really easy to assign properties to these features, such as our label. Go ahead and type .Text after lblHello so it now looks like lblHello.Text. This basically means that what we type after this is going to become our labels text property. There are plenty of other properties we can set such as the font, colours and much more but for this tutorial text is all we will care about. So now we should have in the form load section lblHello.Text after this we now should type = “Hello World”. This now means we have lblHello.Text = “Hello World”:
We are now done! To confirm this we should go ahead and loom at the top menu, click the green start button and after a few seconds this should pop up:
Congrats on your first ever program, let us recap over what we have just done. We have successfully downloaded VB 2010 Express edition, started a new WFA, placed a label, assigned the name of a label to lblHello, gone into our code view, written the code lblHello = “Hello World” and ran it!
If you happened to get any bugs or have any queries please do not hesitate to question me below. Over the next few days I will write another tutorial which will enable us to create an integer and add a button! Until then though keep programming!
I’ve been interested in gaming and computing for many years and using this knowledge I create videos for Dragonblogger.com’s youtube and occasional articles for the site. I’ve been writing for Dragonblogger for over a year and it’s been awesome. My content usually is around product reviews and gaming.