0% found this document useful (0 votes)
37 views22 pages

Assignmant Bca

The document contains 10 code snippets showing programs written in Visual Basic .NET to perform various tasks like calculating area and volume of a box, performing mathematical operations, generating Fibonacci series using recursion, adding matrices, displaying movie information based on cinema hall selection from a list box, validating a login form, calculating employee pay and overtime, printing squares less than 50 and calculating their sum, calculating book sales totals and discounts, and calculating car rental charges based on miles driven.

Uploaded by

kyobatau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views22 pages

Assignmant Bca

The document contains 10 code snippets showing programs written in Visual Basic .NET to perform various tasks like calculating area and volume of a box, performing mathematical operations, generating Fibonacci series using recursion, adding matrices, displaying movie information based on cinema hall selection from a list box, validating a login form, calculating employee pay and overtime, printing squares less than 50 and calculating their sum, calculating book sales totals and discounts, and calculating car rental charges based on miles driven.

Uploaded by

kyobatau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

OUTPUT

1. Write a program to find the area of a box(Length* breadth *height ) using class

Public Class Form1


Public Class box
Public length As Integer
Public breadth As Integer
Public height As Integer
Public volume As Integer
Public area As Integer
End Class
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim b1 As box = New box()
b1.length = Val(TextBox1.Text)
b1.breadth = Val(TextBox2.Text)
b1.height = Val(TextBox3.Text)
b1.area = 2 * (b1.length * b1.breadth + b1.breadth * b1.height + b1.height * b1.length)
b1.volume = b1.length * b1.breadth * b1.height
TextBox4.Text = b1.area
TextBox5.Text = b1.volume
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub
End Class
OUTPUT
2. Write a program to perform following operation:
(ADD, SUBTRACT, MULTIPLY, DIVISION, MOD)
Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click TextBox3.Text =


Val(TextBox1.Text) + Val(TextBox2.Text)

End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click TextBox3.Text =


Val(TextBox1.Text) - Val(TextBox2.Text)

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click TextBox3.Text =


Val(TextBox1.Text) * Val(TextBox2.Text)

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click TextBox3.Text =


Val(TextBox1.Text) / Val(TextBox2.Text)

End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click TextBox3.Text =


Val(TextBox1.Text) Mod Val(TextBox2.Text)

End Sub End Class


OUTPUT
3. Write a program, using recursive function to generate Fibonacci Series.
Public Class Form1

Function fib(ByVal n As Integer) As Integer If (n = 0 Or n = 1) Then

Return n Else

Return fib(n - 1) + fib(n - 2) End If

End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim n As Integer


= TextBox2.Text

While (n >= 0)

Dim s As String = fib(n) TextBox1.Text += s + " " n -= 1

End While

End Sub End Class


OUTPUT
4. Write a program to add two matrices.

Module Module1
Sub Main()
Dim m, n, c, d As Int16
Dim first(,) As Int16 = New Int16(5, 5) {} Dim second(,) As Int16 = New Int16(5, 5) {} Dim
sum(,) As Int16 = New Int16(5, 5) {}
Console.WriteLine("Enter the number of rows and columns of matrix") m =
Convert.ToInt16(Console.ReadLine())
n = Convert.ToInt16(Console.ReadLine()) Console.WriteLine("\nEnter the elements of first
matrix\n") c = 0
While c < m d = 0
While d < n
Console.WriteLine("Enter Element [" + c.ToString() + " , " + d.ToString() + "]") first(c,
d) = Convert.ToInt16(Console.ReadLine())
d = d + 1 End While c = c + 1
End While
Console.WriteLine("Enter the elements of second matrix") c = 0
While c < m d = 0
While d < n
Console.WriteLine("Enter Element [" + c.ToString() + " , " + d.ToString() +second(c, d)
= Convert.ToInt16(Console.ReadLine()) d = d + 1
End While c = c + 1
End While c = 0
While c < m d = 0
While d < n
sum(c, d) = first(c, d) + second(c, d) d = d + 1
End While c = c + 1
End While
Console.WriteLine("Sum of entered matrices:-") c = 0
While c < m d = 0
While d < n
Console.Write(" " + sum(c, d).ToString()) d = d + 1
End While Console.WriteLine() c = c + 1
End While Console.ReadKey()
End Sub
End Module
OUTPUT
5. Create a list box, which contains names of all cinema halls of NCR. If you choose name of
cinema hall, label display information regarding all movies running in the cinema halls.

Public Class Form1


Private Sub ListBox1_SelectedIndexChanged (sender As Object, e As EventArgs) Handles
ListBox1.SelectedIndexChanged
Dim n As String = ListBox1.SelectedItem

If (n = "Miraj M4U") Then


TextBox1.Text = "URI Bumblebee Simmba”

ElseIf (n = "World Square")

Then TextBox1.Text = "URI


The accidental Prime Minister" ElseIf (n = "DLF") Then

TextBox1.Text = "URI The accidental Prime Minister Simmba"


ElseIf (n = "GIP") Then TextBox1.Text = "URI
NTR
The acidental Prime Minister

Simmba"
ElseIf (n = "Wave") Then TextBox1.Text = "URI
The accidental Prime Minister
KGF
NTR
Simmba"
End If

End Sub

End Class
OUTPUT
6. Create and validate login form.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Form2.Hide()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

If (TextBox1.Text = "7052776" And TextBox2.Text = "123###aks") Then


MessageBox.Show("Hello Akshansh")
Form2.Show()
Else
MessageBox.Show("Invalid credentials")

End If
End Sub

Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles


CheckBox1.CheckedChanged
If TextBox2.UseSystemPasswordChar = True Then

TextBox2.UseSystemPasswordChar = False
Else
TextBox2.UseSystemPasswordChar = True

End If
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Form1.Hide()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click Application.Restart()
End Sub
End Class
OUTPUT
7. Write a program to calculate pay that takes two parameter hours and wages and
Display the total pay of an employee.

Public Class Form1


Dim hour, basic, overtime As Integer

hour = Val(TextBox2.Text)
basic = Val(TextBox1.Text)
overtime = Val(TextBox3.Text)

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


TextBox4.Text = basic + hour * overtime
End Sub

End Class
OUTPUT
8. Write a program to print first n square less than 50 and print the sum of the all the square
of the n number

Public Class Form1


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim n As Integer = 1
Dim sum As Integer = 0
Dim x As String
While n * n < 50
x=n*n
sum += n * n
n += 1
TextBox1.Text += x + " "
End While
TextBox2.Text = sum
End Sub
End Class

OUTPUT
9. Create a project for book sales. Make text boxes for quantity, title and price with
labels.
Calculate total price, discount (15%) and discounted price.
Make command buttons for calculate, clear and exit.

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim price As Integer = Val(TextBox1.Text) * Val(TextBox3.Text)


TextBox4.Text = price
TextBox5.Text =price -(0.15*price)

End Sub
End Class

OUTPUT
10.Create a project for the local car rental agency that calculates rental charges..
Public Class Form1

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


Dim miles As String = Val(TextBox6.Text) - Val(TextBox5.Text)
Dim cost As String = Val(TextBox7.Text * 15) + (Val(TextBox6.Text) -
Val(TextBox5.Text)) * 0.5 Label9.Text += cost
Label8.Text += miles
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click


Application.Exit()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Application.Restart()
End Sub
End Class

You might also like