If you expect to become a Visual Basic expert just by following this tutorial, you are wrong. Becoming an expert is something that takes a LOT of time and study. You can't just create a program or two and declare yourself a master. It involves developing your own style of programming, as well as debugging, evaluating, and improving other people's code. Something like "you can't tell if you're smart unless the people around you are either dumber or smarter" -- and you can't figure that out until you get out there and just keep working at it.
This tutorial is going to gloss over most of the basics that you would learn in a Microsoft certified class, and maybe even more than that (I only have so many MBs of webspace!). But for many people, just getting started is a hassle; it's like trying to get on the Pasadena freeway {you have about 5 feet to match the speed of traffic and merge}! We're going to build a basic calculator in the next few weeks. Hopefully, by the time you're done, you'll be interested in either finishing the more complex calculations or starting new projects that are more meaningful to you.
Obviously, this tutorial assumes that you have a licensed copy of Microsoft Visual Basic. I stress licensed, as I used to work for Microsoft, and as a programmer myself, I would like to be acknowledged for my work, however small or big it may be. And money usually seems to please most people. In any case, believe me, a couple hundred dollars now will mean thousands for you once you master your VB skills. So please don't steal or use illegal software. For the most part, you can use these same principles using other programming languages, and we're going to do just that using HTML and ASP. But if you wanted to learn PowerBuilder or C++, the steps are relatively the same.
Whatever you decide to do, I highly recommend that you do what you like the best. Programmers are known for spending most of their time awake thinking about code -- and it's not like I'm suggesting that you buy thick-lensed glasses and a pocket protector (most of you probably already have them anyway). But if you like sewing, try to create a program to teach someone else how to sew. Or a program to catalog your Pokemon cards or your favorite recipes. Anything that you feel is important can be made into a program, so let's get started!
Robert
Most of you are already familiar with the general tools of a VB programmer, especially if you're reading this page. You started your Web browser by clicking on its icon (or button). You read a few lines of text (or label), and clicked on a hyperlink to get here. On other sites, you had to enter your information in the appropriate spaces (or textboxes) -- for the most part, that was the result of someone's programming. Take a look at the toolbar your Web browser; you click on a button and something happens.
On a calculator, you have many buttons, and a simple display. Most of us know how to operator a calculator: when you push the number buttons, the corresponding number appears on the display. The display holds both the INPUT (the values you put into a calculation) and the OUTPUT (the result of the calculation). We're going to build a calculator to do basic addition, subtraction, division, and multiplication. Once we finish that, it will be easy for you to add the other more complex functions, like the logarithmic functions. And we can do this in 5 easy lessons (well, easy for me, but believe me, it will be easy for you once we're through). It may help you to have a REAL calculator next to you, so you have a visual idea of what you're going to build.
When you first open a new VB project, you get a simple, empty form. We want to make it look like a calculator, and that means adding several buttons and a display. The buttons will be made using a CommandButton control, and the display will be a Label control (you could also use a Textbox, but again, we want to be simple for now). Arrange the controls so that they look like this:
Notice that there are 15 buttons and 1 label on this form. The button for the "=" sign is roughly twice the size of the others, and each button contains the appropriate symbol that we all know and hate. The form has the title of "Calculator", and is smaller than the default size that VB starts off with. The label has a "0." in it, and the text is positioned to the right.
"HOLD ON!" you might be telling me. How did I make the form look like that? It involves a little bit of dragging and dropping, as well as copying and pasting. If you are having difficulty making yours look like this, don't despair. I'll give you a few hints, and that should help, but if you're really having trouble, I suggest you open up a Paint program and practice "drawing" this screen using the basic tools there. I'm sorry I can't go into more aesthetic details, but that's something you'll have to pick up as you go.
To change the text on a control, select the control and look in the Property window for either the Caption or Text property. To change the alignment of the text in the control, look for the Alignment property. To resize a form or control, select it and drag one of the boundary points until it looks the way you want it.
You don't have to make it look exactly like mine. You may want it to look different so that it matches your keyboard -- the important thing is to make it look good. If you place the number keys all over the place, it will be difficult for the user to click on the buttons, as they will be confused because it doesn't match their "inner vision" of what a calculator should look like. As a programmer, this "inner vision" is your Holy Grail and your worst enemy -- you want it to match how your user thinks, but they don't always share what they really have in mind. Maybe they're afraid you'll replace them with a computer, or maybe they want to use big words or "geekspeak" so that you'll think highly of them. Some people just don't know how to explain their thoughts. Your value as a programmer will be judged on not only how well you can translate their thoughts into code, but also how well you can extract their thoughts. Most of the eggheads that are programming gods nowadays don't know "how to play with the other children", and that's why they are not as successful as the charismatic leaders who read the latest "For Dummies" book. Always remember, it's not always what you know, but how you present it.
{I'll continue more with this lesson, but right now I have to go grocery shopping. More tomorrow!}