previous page main page next page

It seems clear that we will need three variables - one for each of the marks - and another one for the average. We'll call them MarkA, MarkB, MarkC and Average. They are declared in the General Declarations section:
 

Option Explicit

Dim MarkA As Integer
Dim MarkB As Integer
Dim MarkC As Integer
Dim Average
 

We note that MarkA, MarkB and MarkC are integers but that Average is unlikely to be an integer so we just declare it but don't specify a type.
 

  • enter the code
  • enter the code for the Exit button
     

Consider, then, exactly what we want the program to do. The idea is that the user will set the three exam marks using the scroll bars. When the user clicks the Calculate button, the program will take the three marks, calculate the average and display it in the label. It will also display images in the image boxes - a 'smiley' if the person has passed, and a 'not-so-smiley' if they have failed...

So where do these images come from? Well Visual Basic comes with a selection of icons and bitmapped images. Have a look on your system for a sub-directory wherever Visual Basic has been installed - something similar to:

c:\vb\icons\misc\

and the two images we're looking for are called face01.ico and face02.ico. If you can't find them on your system then you could draw your own using a paint package or you could use any other images with a .bmp or .ico file extension. The images themselves are not important, it's how they are used that you should be focusing on.

Continued...
 

previous page main page next page ©  ePublish Scotland  1999