You are on page 1of 3

PRACTICAL NO 17

a) Implement a program to accept values from combobox and display average of this
in message box using class:-
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("1")
ComboBox1.Items.Add("2")
ComboBox1.Items.Add("3")
ComboBox1.Items.Add("4")
ComboBox1.Items.Add("5")
ComboBox1.Items.Add("6")
ComboBox1.Items.Add("7")
ComboBox1.Items.Add("8")
ComboBox1.Items.Add("9")
ComboBox1.Items.Add("10")
ComboBox2.Items.Add("1")
ComboBox2.Items.Add("2")
ComboBox2.Items.Add("3")
ComboBox2.Items.Add("4")
ComboBox2.Items.Add("5")
ComboBox2.Items.Add("6")
ComboBox2.Items.Add("7")
ComboBox2.Items.Add("8")
ComboBox2.Items.Add("9")
ComboBox2.Items.Add("10")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim o1 As New Combo
o1.avg(Val(ComboBox1.SelectedItem), Val(ComboBox2.SelectedItem))
End Sub
End Class
Public Class Combo
Dim a, b As Integer
Public Function avg(ByVal v1 As Integer, ByVal v2 As Integer)
a = v1
b = v2
Dim c As Integer
c = (a + b) \ 2
MsgBox("The Average is : " & c)
End Function
End Class
b) WAP to identify volume of box class, with three data members, length, breadth and
height:-
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim o1 As New vol
o1.cal(Val(TextBox1.Text), Val(TextBox2.Text), Val(TextBox3.Text))
End Sub
End Class
Public Class vol
Dim a, b, c As Integer
Public Function cal(ByVal len As Integer, ByVal bre As Integer, ByVal hei As
Integer)
Dim v As Integer
a = len
b = bre
c = hei
v=a*b*c
MsgBox("The Volume is : " & v)
End Function
End Class

You might also like