previous page main page next page

Let's look at some of the code then.
 

  • enter the familiar code for the Exit button
  • enter the following code for the Change event of the leftmost vertical scroll bar:
     

Private Sub vsbA_Change()

txtA.Text = vsbA.Value

End Sub
 

  • copy the same line of code to the Scroll event of the scroll bar
  • you should now be able to enter code for the Change and Scroll events of the other two scroll bars in a similar way
  • run the program to check that things are working OK so far
  • save your project
     

Now we come to the code for the Calculate button and this is where most of the action takes place. It looks like this:
 

Private Sub cmdCalculate_Click()

'assign marks to variables
MarkA = vsbA.Value
MarkB = vsbB.Value
MarkC = vsbC.Value

'calculate average
Average = (MarkA + MarkB + MarkC) / 3

'display the average mark
lblAverage.Caption = "average is " + Str(Average)

'display the pictures
If MarkA > Average Then
  imgA.Picture = LoadPicture("c:\vb\icons\misc\face02.ico")
Else
  imgA.Picture = LoadPicture("c:\vb\icons\misc\face01.ico")
End If

If MarkB > Average Then
  imgB.Picture = LoadPicture("c:\vb\icons\misc\face02.ico")
Else
  imgB.Picture = LoadPicture("c:\vb\icons\misc\face01.ico")
End If

If MarkC > Average Then
  imgC.Picture = LoadPicture("c:\vb\icons\misc\face02.ico")
Else
  imgC.Picture = LoadPicture("c:\vb\icons\misc\face01.ico")
End If

End Sub
 

Continued...
 

previous page main page next page ©  ePublish Scotland  1999