BCA-III A DEEPAK KUMAR ROLL NO.
03217702017
WAP to build a simple calculator
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text
c=a-b
TextBox3.Text = c
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim a, b As Integer
Dim c As Double
a = TextBox1.Text
b = TextBox2.Text
c=a/b
TextBox3.Text = c
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text
c=a+b
TextBox3.Text = c
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim a, b As Integer
Dim c As Double
a = TextBox1.Text
b = TextBox2.Text
c=a*b
TextBox3.Text = c
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to find area and perimeter of square,rectangle,circle,triangle
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim r As Integer
Dim area As Double
r = TextBox1.Text
area = 3.14 * r * r
TextBox8.Text = area
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim r As Integer
Dim p As Double
r = TextBox1.Text
p = 2 * 3.14 * r
TextBox8.Text = p
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim s, area As Integer
s = TextBox2.Text
area = s * s
TextBox8.Text = area
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim s, p As Integer
s = TextBox2.Text
p=4*s
TextBox8.Text = p
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim l, b, area As Integer
l = TextBox3.Text
b = TextBox4.Text
area = l * b
TextBox8.Text = area
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim l, b, p As Integer
l = TextBox3.Text
b = TextBox4.Text
p = 2 * (l + b)
TextBox8.Text = p
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim h, b As Integer
Dim area As Double
h = TextBox5.Text
b = TextBox6.Text
area = 0.5 * h * b
TextBox8.Text = area
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
Dim l, b, h, p As Integer
l = TextBox5.Text
b = TextBox6.Text
h = TextBox7.Text
p=l+b+h
TextBox8.Text = p
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to execute try catch finally block
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim i, result As Integer
i = InputBox("Enter Value Of i:",, "Type Here...")
result = 1 / i
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
MessageBox.Show("Finally Block Executed")
End Try
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to find largest of three numbers
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, c As Integer
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
If (a > b And a > c) Then
MsgBox("Largest Number Is " & a)
ElseIf (b > a And b > c) Then
MsgBox("Largest Number Is " & b)
Else
MsgBox("Largest Number Is " & c)
End If
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to show result of student
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Integer
a = InputBox("Enter marks out of 100")
If (a >= 90) Then
MsgBox("EXCELLENT", 1, "RESULT")
ElseIf (a < 90 And a >= 75) Then
MsgBox("VERY GOOD", 1, "RESULT")
ElseIf (a < 75 And a >= 50) Then
MsgBox("PASS", 1, "RESULT")
ElseIf (a < 50 And a >= 0) Then
MsgBox("FAIL", 1, "RESULT")
End If
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to demonstrate dynamic array
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim marks(), i As Integer
ReDim marks(2)
For i = 0 To 2
marks(i) = InputBox("Enter the values for array:")
Next
ReDim Preserve marks(9)
For i = 3 To 9
marks(i) = InputBox("Enter the values for array:")
Next
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
For i = 0 To 9
TextBox1.Text &= " " & marks(i)
Next
End Sub
End Class
WAP to calculate factorial
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim i, fact As Integer
fact = TextBox1.Text
i = fact - 1
While (i >= 1)
fact *= i
i -= 1
End While
TextBox2.Text = fact
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
End Sub
End Class
WAP to print Fibonacci series
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a, b, c, n As Integer
a=0
b=1
c=a+b
n = InputBox("Enter The Number Upto Which The Series Has To Be Printed")
TextBox1.Text = 0
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
While (c <= n)
TextBox1.Text &= " " & c
c=a+b
a=b
b=c
End While
End Sub
End Class
WAP to print grade using select case
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim grade As Char
grade = TextBox1.Text
Select Case (grade)
Case "a", "A"
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
MessageBox.Show("EXCELLENT")
Case "b", "B", "c", "C"
MessageBox.Show("VERY GOOD")
Case "d", "D"
MessageBox.Show("PASS")
Case "e", "E"
MessageBox.Show("FAIL")
Case Else
MessageBox.Show("INVALID INPUT!!!")
End Select
End Sub
End Class
WAP to demonstrate Array List
Public Class Form1
Dim a As New ArrayList()
Dim x, y As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
x = InputBox("Enter An Element")
a.Add(x)
TextBox1.Text = ""
For y = 0 To a.Count - 1
TextBox1.Text &= " " & a.Item(y)
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
y = InputBox("Enter Index Number:")
x = InputBox("Enter An Element:")
a.Insert(y, x)
TextBox1.Text = ""
For y = 0 To a.Count - 1
TextBox1.Text &= " " & a.Item(y)
Next
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
x = InputBox("Enter Name Of Element")
a.Remove(x)
TextBox1.Text = ""
For y = 0 To a.Count - 1
TextBox1.Text &= " " & a.Item(y)
Next
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
y = InputBox("Enter Index To Remove Element")
a.RemoveAt(y)
TextBox1.Text = ""
For y = 0 To a.Count - 1
TextBox1.Text &= " " & a.Item(y)
Next
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
a.Sort()
TextBox1.Text = ""
For y = 0 To a.Count - 1
TextBox1.Text &= " " & a.Item(y)
Next
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
TextBox1.Text = ""
MsgBox(a.Count)
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to demonstrate enumeration
Public Class Form1
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
Enum color
red = 4445
blue = 1234
yellow = 8888
End Enum
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox(“CODE OF RED: “ & color.red)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MsgBox(“CODE OF BLUE: “ & color.blue)
End Sub
Private Sub Button3_Click_1(sender As Object, e As EventArgs) Handles Button3.Click
MsgBox(“CODE OF YELLOW: “ & color.yellow)
End Sub
End Class
WAP to find number is prime or not
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim b As Boolean = True
Dim i, a As Integer
a = TextBox1.Text
For i = 2 To a - 1
If (a Mod i = 0) Then
b = False
End If
Next
If (b = True) Then
MsgBox("Number Is Prime")
Else
MsgBox("Number Is Not Prime")
End If
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to print prime number between 2 to 100
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim b As Boolean = True
Dim i, j As Integer
For j = 2 To 100
b = True
For i = 2 To j - 1
If (j Mod i = 0) Then
b = False
Exit For
End If
Next
If (b = True) Then
TextBox1.Text += " " & j
End If
Next
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to find sum and average of an array
Public Class Form1
Dim a As New ArrayList()
Dim b, x As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
b = InputBox("Enter An Element", "ADD")
a.Add(b)
TextBox1.Text = ""
For x = 0 To a.Count - 1
TextBox1.Text &= " " & a.Item(x)
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
x=0
For b = 0 To a.Count - 1
x += a.Item(b)
Next
MsgBox(x,, "Sum Of Array")
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
x=0
For b = 0 To a.Count - 1
x += a.Item(b)
Next
x = x / a.Count
MsgBox(x,, "Average Of Array")
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to reverse a number
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Integer
For a = TextBox1.TextLength - 1 To 0 Step -1
TextBox2.Text += TextBox1.Text(a)
Next
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to insert and delete an element in an array from a specified position and also
print smallest element in array
Public Class Form1
Dim ar As New ArrayList
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Try
ar.RemoveAt(Int(InputBox("Enter index")) - 1)
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
ar.Remove(Int(InputBox("Enter item")))
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
ar.Insert(InputBox("Enter Index") - 1, Int(InputBox("Enter new item")))
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ar.Add(Int(InputBox("Enter new item")))
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
TextBox1.Text = ""
For i = 0 To ar.Count - 1
TextBox1.Text = TextBox1.Text + (i + 1).ToString() + ". " + ar.Item(i).ToString() +
vbNewLine
Next
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
ar.Sort()
MessageBox.Show(ar(0), "Smallest Element")
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
WAP to make calculator which perform: Addition, Subtraction, Multiplication,
Division, Modulus and Power. According to user choice. Use select case.
Public Class Calculator
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
opr.Text = "+"
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
opr.Text = "-"
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
opr.Text = "*"
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
opr.Text = "/"
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
opr.Text = "^"
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
opr.Text = "%"
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim n1, n2 As Integer
n1 = Int(num1.Text)
n2 = Int(num2.Text)
Select Case opr.Text
Case "+"
result.Text = n1 + n2
Case "-"
result.Text = n1 - n2
Case "*"
result.Text = n1 * n2
Case "/"
result.Text = n1 / n2
Case "%"
result.Text = n1 Mod n2
Case "^"
Dim mul As Integer = 1
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017
For i = 0 To n2 - 1
mul *= n1
Next
result.Text = mul
End Select
End Sub
End Class
BCA-III A DEEPAK KUMAR ROLL NO. 03217702017