Wednesday, March 26, 2014

A VB6 Exercise For 1st. year student of Mechatronics Dept.

Exercise:Write a VB6 Program to Calculate Average of 5 input values when "average" key is pressed with the appearance of an Image named "Aver.jpg" as shown below, there is another Button key "RESET" that when pressed resets all values and makes image invisible!

Solution:
Dim Average As Single
Private Sub Command1_Click()
Average = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text)
Average = Average / 5
Label1.Caption = Label1.Caption & Average
Image1.Visible = True
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Label1.Caption = ""
Image1.Visible = False

End Sub

0 Comments:

Post a Comment

السلام عليكم...سارد بعد قرائتي للتعليق...شكرا

<< Home