previous page main page next page

All well and good, but what's supposed to happen? To run the project look for the 'start' button on the toolbar - it's a small right-pointing black arrow.
 

  • click the start button
  • try clicking some of the buttons on the form
     

Nothing happens, but this isn't surprising really because all we've done is to design how the form looks and not how it behaves. If you like, think of this as the visual part of Visual Basic. Now we've got to look at the programming part of it...

The project is still running - this is indicated on the top title bar - and will be until you tell it to stop. To do this, you should now notice a button with a small black square on it just a little to the right of the start button - it was 'greyed out' before, making it inactive. After all, it doesn't make much sense to stop a project that hasn't been started does it? Likewise, when the project is running, the start button is similarly 'greyed out'.
 

  • click the stop button
     

Before we start thinking about the programming code, let's just be clear about what we want the program to do. What is meant to happen when the user presses each of the buttons?

The button labelled Display should result in a message being displayed in the text box.

The button labelled Clear should result in any text in the text box being cleared.

The button labelled Exit should cause the program to stop running.

But why can't the user just press the Stop button on the toolbar? Well the short answer is that they can. What we're doing, though, is looking ahead to when we produce a self-contained executable program. Suppose, for example, that you wrote a games program that you thought was so good that other people might want to use it. You would need to create an executable version of your project so that other people could run it on their machines, bearing in mind that they might not have Visual Basic. Indeed why should they have Visual Basic if all they want to do is use your program? In other words, an executable program is one that can execute on their system without them needing to have Visual Basic installed.

It's an easy enough matter to create an executable file from your project and the option to do that is on the File menu.

So, back to our project. The Exit button is the one that's going to stop the program and is the easiest to write the code for. We'll do that in just a moment but before that, we'd like you to check a couple of settings...
 

  • click Tools then Options... and under the Editor tab make sure that Require Variable Declaration is ticked
  • in the same dialog box, and also under the Editor tab, make sure that Default to Full Module View is not ticked
     

And now to the code...
 

Continued...
 

previous page main page next page ©  ePublish Scotland  1999