Learning Visual Basic

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Learning Visual Basic as PDF for free.

More details

  • Words: 1,277
  • Pages: 6
Learning Visual Basic If you're new to Visual Basic, or even new to programming, this is the place! Visual Basic from the very ground up will be explained. Those of you who are more codewise might find this article slightly boring from a technical perspective ... but Hey!, you're welcome here too! The first thing you need to know, and I mean know, about programming is that it's not magic and you can do it. The people who have trouble learning to program are the ones who expect to have trouble. If you think it's going to be easy, it probably will be for you. So plan on having fun! It's the best way to learn. The second thing is to realize is that the computer is really dumb! I mean stupid, idiotic, and just plain dense. That's why it has to be told each and every thing to do ... at some time. The TV and movie plots where the computer is this scheming, thinking, entity are completely wrong. If a computer doesn't have instructions to do something, it will not do anything. Your task as a programmer is to provide those instructions. The flip side of this is that if it's not doing what you intend, then it's because the instructions that it was given were wrong. The main flaw in this is that YOU don't give the computer all of the instructions. It gets a lot of them from other programmers at other times in the form of software like the compiler (the program that turns a 'programming language' like Visual Basic into instructions that the computer can actually understand), the operating system (the program that turns things like your keystrokes into instructions that the computer can actually understand), and software objects (little packages of self contained program code that do things that a lot of people need). So to really understand the instructions that the computer received, you have to have an idea about what all the other instructions are. Welcome to programming! Therefore ... our task in learning Visual Basic is to understand how Visual Basic combines with your instructions (and all the other stuff) to form a complete program. Sponsored Links ProgrammingThe latest & greatest in parallel computing. Visit our expert blog!www.ddj.com/Go-Parallel Visual Basic ProgrammingFree Online Discussion Boards for VB & Other Programming Languages.www.daniweb.com VidyanoBuild Rich Client WPF applications Get your free Trial now!www.vidyano.com Fortunately, Visual Basic takes care of virtually all of the details for you. But it's a good idea to know what's happening "under the covers". Here's a picture of what all this looks like.

By the way, this is usually called a 'Flow Chart'. A lot of people insist that you draw a flow chart of any program before you try to write it. It's a good idea, especially for people just starting out. But remember rule number 1: If it's not fun, don't do it. As the previous flowchart showed, you have to have the Basic software before you can complete a working program. The good news is that Microsoft does provide a first class development environment called Visual Basic Express. (You can read all about it in my complete tutorial - click here.) The bad news is that we're not going to base this tutorial on Microsoft's free system. We're going to assume that you're using Visual Basic version 6.0. More bad news is that it's becoming very difficult to actually buy a new copy of VB 6. Microsoft is doing a pretty good job of exterminating it in the retail market because you simply can't buy it from them anymore. The only copies that are available are left over from years ago. In fact, Microsoft stopped supporting it as a 'Mainstream' product in 2005. The reason we're using VB 6.0 is first, to provide a really great VB environment. (Although Microsoft doesn't support it anymore, we do here and it is pretty great.) And second, to provide a tutorial that will match the software that a lot of people still actually use, in spite of Microsoft's position on it. For the rest of you, make sure you have VB 6 installed and then start it up! You should see a development environment that looks something like this:

Notice that in the previous flowchart, the arrows pointed both ways from the computer to the 'operating system' and 'software libraries'. That is because you can actually make your own software modifications using VB. That's what some of the other icons are for. But for now, click the default "Standard EXE" icon and then click the "Open" button. You should now see something that looks like this:

There are a lot of display options at this point and you might see other parts of Visual Basic on your computer such as the 'Project Explorer' window ...

... the 'Toolbox' ...

... or several other things. This leads to the next point. Your VB development environment has a lot of different components and you don't have to know what they all are right away. We're going to keep things as simple as possible and avoid discussing anything that you don't absolutely need. As you gain skill in VB, you'll figure out the new stuff. Pop Quiz! The most important feature of the first version of Visual Basic that helped make it a smash software hit was: • •

It made it easy to create graphical programs for Windows It made it easy to use the 'event driven programming' model Time's up!

The author's answer is 'event driven programming' even though many experts and Microsoft's advertising tend to suggest the first answer. The concept behind 'event driven programming' is not as easy to explain as programming for Windows. You can explain the Windows programming by simply saying, "Wow! Now I can create programs in just a few minutes without knowing a thing about C++." One problem is that the core idea is just too simple to seem that important. Here it is: Your VB program doesn't 'do' anything except sit there and wait for 'an event'. Then it does different things depending on what the event is.

Which event? That's up to you, the programmer. What does it do? That's up to you too. Let's put this in pictures. Here's what happens when a typical VB program is started.

So what good is this? This is the magic ingredient that makes the program 'interactive'. The form and buttons displayed on the computer screen is part of what is called a GUI, or Graphic User Interface. That simply means that the pictures on the screen interact with the mouse, keyboard, or maybe even something else. In the case of a touch screen, it might be your finger. Now, the program can do one thing when a user clicks button 'A' and something completely different when button 'B' is clicked. The 'event' is that one or the other button is clicked. Your program code is in little chunks called 'event code'. Let's look at an example of event code. Each button is an 'object' in programming terms and has a name that you, the programmer, can control. We'll use the name 'CommandA' for button 'A' and 'CommandB' for button 'B'. Suppose we wanted to simply display a message stating which button was clicked. Here's the code that would do the trick.

The idea now is simply to understand the relationship between 'objects', 'event code', and your program. Visual Basic helps you create a visual interface, called a GUI and helps you enter event code that interacts with the objects. We'll actually program this example in Learning VB 6 or Learning VB.NET.

Related Documents

Learning Visual Basic 6
November 2019 6
Visual Basic
June 2020 18
Visual Basic
September 2019 35
Visual Basic
May 2020 28
Visual Basic
November 2019 35