Part 1
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.
Part 2
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.
Part 3
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.
Source http://visualbasic.about.com
Reviews:
Post a Comment