Wednesday, March 26, 2014

Another VB6 Exercise for 1st. year Mechatronics Dept. students

Exercise: Write a VB6 Program to Calculate the Areas shown on the following Form according to the Option selected along with Unit of measurement. Three Command Buttons are to be used as illustrated below:
Solution:
Private Sub Command1_Click()
Dim x As Single
Dim z As Single
Dim r As Single
Dim y1 As Single
Dim y2 As Single
Dim y3 As Single

If Option1.Value = True Then
'Square
x = Val(Text1.Text): y1 = x ^ 2: Label4.Caption = Label4.Caption & " Square  =": Text4.Text = y1
Else
If Option2.Value = True Then
'Rectangle
x = Val(Text2.Text): z = Val(Text5.Text): Label4.Caption = Label4.Caption & " Rectangle  =": y2 = x * z: Text4.Text = y2
Else
If Option3.Value = True Then
'circle
r = Val(Text3.Text): y3 = r ^ 2 * (22 / 7): Label4.Caption = Label4.Caption & " Circle  =": Text4.Text = y3
End If
End If
End If
Label6.Caption = Text6.Text
Label7.Caption = "2"

End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Label4.Caption = "Area of "
Label6.Caption = ""
Label7.Caption = ""

End Sub

Private Sub Command3_Click()
End
End Sub

0 Comments:

Post a Comment

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

<< Home