Professional Documents
Culture Documents
Assignment-1
Source code:-
Imports System
Module Module1 Sub Main()
Console.WriteLine(" sherya thakur BCA 3rd year")
Dim a, b, c As Integer
Console.Write("Enter the values of a , b and c :")
a = CInt(Console.ReadLine()) b
= CInt(Console.ReadLine()) b
= CInt(Console.ReadLine())
If (a > b) And (a > c) Then
Console.WriteLine("Maximum=" + a.ToString())
ElseIf (b > a) And (b > c) Then
Console.WriteLine("Maximum=" + b.ToString())
Else
Console.WriteLine("Maximum=" + c.ToString())
End If
Console.ReadLine()
End Sub
End Module Output:
Assignment 2
sourceCode:
Imports System
Module Number
Sub Main()
Console.WriteLine(" sherya thakur BCA 3rd year")
Dim num As Integer = 0
Console.Write("Enter number: ") num =
Integer.Parse(Console.ReadLine())
If num> 0 Then
Console.WriteLine("Entered Number is Positive.")
ElseIfnum< 0 Then
Console.WriteLine("Entered Number is Negative.")
Else
Console.WriteLine("Entered Number is Zero.")
End If
Console.ReadLine()
End Sub
End Module Output:
Assignment 3
Assignment 4
Assignment 5
Program-Write a program to find all roots of a quadratic equation.
sourceCode:
Imports System
Module Module1
Sub Main()
Console.WriteLine(" sherya thakur BCA 3rd year")
Dim a, b, c, s, r1, r2 As Double
Console.WriteLine("Enter 3 number :
") a = Console.ReadLine() b =
Console.ReadLine() c =
Console.ReadLine() s = (b * b - (4 * a *
c)) ^ 2 r1 = (b + s) / (2 * a) r2 = (-b + s)
/ (2 * a)
Console.WriteLine("root 1: {0} ", r1)
Console.WriteLine("root 2: {0} ", r2)
Console.ReadLine()
End Sub
End Module Output:
Assignment 6
Program-Design an application to input marks of five subjects Physics,
Chemistry, Biology, Mathematics and Computer. Calculate percentage and
grade according to following: Percentage >= 90% : Grade A
Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 90% : Grade F sourceCode:
Module Student
Sub Main()
Console.WriteLine(" sherya thakur BCA 3rd year")
Dim p, c, b, m, cp, total As Integer
Dim per As Decimal
Console.WriteLine("Enter marks of Physics, Chemistry, Biology, Mathematics and Computer :")
p = Console.ReadLine() c = Console.ReadLine() b = Console.ReadLine() m =
Console.ReadLine()
cp = Console.ReadLine() total
=0
Console.WriteLine("Entered marks of" + vbCrLf + "Physics = {0}" + vbCrLf + "Chemistry = {1}"
+ vbCrLf + "Biology = {2}" + vbCrLf + "Mathematics = {3}" + vbCrLf + "Computer = {4}", p,
c, b, m, cp)
total = (p + c + b + m + cp)
Console.WriteLine(vbCrLf + "Total Marks = {0}", total) per
= ((p + c + b + m + cp) / 500) * 100
Console.WriteLine(vbCrLf + "Percentage = {0}", per)
If (per >= 90) Then
Console.WriteLine("Grade A")
ElseIf (per >= 80) Then
Console.WriteLine("Grade B")
ElseIf (per >= 70) Then
Console.WriteLine("Grade C")
ElseIf (per >= 60) Then
Console.WriteLine("Grade D")
ElseIf (per >= 40) Then
Console.WriteLine("Grade E")
Else
Console.WriteLine("Grade F")
End If
Console.ReadLine()
End Sub
End Module
Output:
Assignment 7
Program-Design an application to input basic salary of an employee and
calculate its Gross salary according to following:
Basic Salary <= 10000 : HRA = 20%, DA =80% Basic
Salary <= 20000 : HRA = 25%, DA =90%
Basic Salary > 20000 : HRA = 30%, DA =95% sourceCode:
Module Module3
Sub Main()
Console.WriteLine(" sherya thakur BCA 3rd year")
Dim hra, da, bs, gs As Decimal
Console.WriteLine(vbCrLf + "Enter Basic Salary : ")
bs = Console.ReadLine() If (bs<= 10000) Then hra =
bs * (20 / 100) da = bs * (80 / 100) ElseIf (bs<=
20000) Then hra = bs * (25 / 100) da = bs * (90 /
100) Else hra = bs * (30 / 100) da = bs * (95 / 100)
End If
gs = bs + da + hra
Console.WriteLine(vbCrLf + "Your Gross salary is {0}", gs)
Console.ReadLine()
End Sub
End Module Output:
Assignment 8
Program-Design an application to input electricity unit changes and calculate
total electricity bill according to the given condition:
For first 50 units Rs. 0.50/unit
For next 100 units Rs. 0.75/unit
Assignment 9
sourceCode:
Module
Sub Main()
Console.WriteLine(" sherya thakur BCA 3rd year")
Dim n, i, b As Integer
Console.WriteLine("Enter a number : ") n
= Console.ReadLine()
Console.WriteLine(" Binary of {0} is : ", n)
For i = 15 To 0 Step -1
b = n >>i If (b = 1)
Then
Console.WriteLine("1")
Else
Console.WriteLine("0")
End If
Next
Console.ReadLine()
End Sub
End Module
Output:
Assignment 11
sourceCode:
Module Module1
Sub Main()
Console.WriteLine("sherya thakur BCA 3rd year ")
Dim a = 0
Dim i = 0 Dim
s=0
console.writeline("Enter any Natural number:")
a = console.readline()
If (a > 0) Then For i
= 1 To a Step 1
s = s + i Next
console.writeline("Sum of natural numbers from 1 to {0} is {1}", a, s) Else
console.writeline("Entered Number is not an integer")
End If
Console.ReadLine()
End Sub
End Module Output:
Assignment 13
sourceCode:
Sub Main()
n = Console.ReadLine()
last = n Mod 10
first = n
While (first >= 10)
first = first / 10
End While
Console.WriteLine("first digit:-{0}", first)
Console.WriteLine("last digit:-{0}", last)
Console.WriteLine("enter any key for exit!!!")
Console.ReadLine()
End Sub
End Module Output:
Assignment- 14
Program-Write a program to enter any number and print its reverse.
sourceCode:
Module Module1
Sub Main()
Console.WriteLine("sherya thakur BCA 3rd year ")
Console.WriteLine("Enter digit:") n
= Console.ReadLine()
u = n While (n
<> 0) m = n
Mod 10 r = r *
10 + m n = n \
10
End While
Console.WriteLine("Reverse of {0} is {1}", u, r)
Console.ReadLine()
End Sub
End Module Output
:
Assignment
-15
Program-Write a program to enter any number and check whether the number is palindrome
or not.
sourceCode: Module
Module1
Sub Main()
Console.WriteLine("sherya thakur BCA 3rd year ")
Dim number As Integer = 0
Dim remainder As Integer = 0
Dim reverse As Integer = 0
Dim temp As Integer = 0
Console.WriteLine("Enter your number: ") number
= Console.ReadLine()
Console.WriteLine("Entered number is : {0} ", number)
temp = number While (number > 0) remainder =
number Mod 10 reverse = reverse * 10 + remainder
number = number / 10 End
While
If temp = reverse Then
Console.WriteLine("Entered Number is palindrome") Else
Console.WriteLine("Entered Number is not palindrome")
End If
Console.ReadLine()
End Sub
End Module
Output :
Assignment
-16
Program-Write a program to check whether a number is Armstrong number or not.
sourceCode: Module
Module6
Sub Main()
Console.WriteLine("sherya thakur BCA 3rd year ")
Dim number As Integer = 0
Dim temp As Integer = 0
Dim remainder As Integer = 0
Dim result As Integer = 0
Console.WriteLine("Enter the number: ") number
= Console.ReadLine()
Console.WriteLine("Entered number is : {0} ", number)
temp = number While (temp > 0) remainder = (temp
Mod 10)
result = result + (remainder * remainder * remainder) temp
= temp \ 10
End While
If (number = result) Then
Console.WriteLine("armstrong")
Else
Console.WriteLine("not armstrong")
End If
Console.ReadLine()
End Sub
End Module Output
:
Assignment
-17
Assignment -18
Sub Main()
Assignment -19
Source Code:
Module Module9
Sub Main()
Console.WriteLine("sherya thakur BCA 3rd year ")
Dim m(100), i, n As Integer console.writeline("Enter
the numbers :-")
n = console.readline() For
i = 1 To n
console.writeline("Enter integers {0}", i)
m(i) = console.readline() Next
console.writeline("Negative numbers in the Array are :- ")
For i = 1 To n If (m(i) < 0)
Then
console.writeline("{0}",
m(i))
End If
Next
Console.Writew+Line(" Press any key to exit...")
Console.ReadKey()
End Sub
End Module
Output :
Assignment-20
Output:
Assignment- 21
Program:-Design the application that accepts the item name from the user and add it to a
listbox and combobox:
Assignment 22
Program -Create an application that offers various food items to select from
check boxes and a mode of payment using radio button. It then display the
total amount payable sourceCode:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Console.WriteLine("("sheryathakur BCA 3rd year ")
Dim sum As Integer
If (CheckBox1.Checked) Then
sum = sum + 60
End If
If (CheckBox2.Checked) Then
sum = sum + 80
End If
If (CheckBox3.Checked) Then
sum = sum + 100
End If
If (CheckBox4.Checked) Then
sum = sum + 120
End If
If (CheckBox5.Checked) Then
sum = sum + 130
End If
If (RadioButton1.Checked) Then
Label1.Text = sum
Label2.Text = "is paid by Cash"
Else
Label1.Text = sum
Label2.Text = "is paid by Card"
End If
Console.ReadLine()
End Sub End
Class
Output :
Assignment.23
Program : Create an application to implement the working of Context menu on
textbox.
Source code:
Me.Close()
End Sub
End Class
Output :-
Assignment-24
Program -WAP to illustrate all functionalities of list box and combo box.
sourceCode:
public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles
MyBase.Load
' Set the caption bar text of the form.
Me.Text = "tutorialspont.com"
' creating multi-column and multiselect list box
ListBox1.MultiColumn = True
ListBox1.SelectionMode = SelectionMode.MultiExtended
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
ListBox1.Items.Add("Safety")
ListBox1.Items.Add("Security")
ListBox1.Items.Add("Governance")
ListBox1.Items.Add("Good Music")
ListBox1.Items.Add("Good Movies")
ListBox1.Items.Add("Good Books")
ListBox1.Items.Add("Education")
ListBox1.Items.Add("Roads")
ListBox1.Items.Add("Health")
ListBox1.Items.Add("Food for all")
ListBox1.Items.Add("Shelter for all")
ListBox1.Items.Add("Industrialisation")
ListBox1.Items.Add("Peace")
ListBox1.Items.Add("Liberty")
ListBox1.Items.Add("Freedom of Speech")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
ListBox1.Sorted = True
End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
ListBox1.Items.Remove(ListBox1.SelectedItem.ToString)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
Label1.Text = ListBox1.Items.Count
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedIndexChanged
Label2.Text = ListBox1.SelectedItem.ToString()
End Sub
End Class
Output:-
Assignment
– 25
Program:- WAP using a checkboxes for the following font effect:- •
Bold
• Italic
• Underline
• Increasing font size
• Decreasing font size
• Font color
Source code:-
Public Class Form1
Assignment
-26
sourceCode:
Public Class Form1
Output :
Assignment
– 27
Program:- WAP to lauch a rocket using picturebox and time control
Source code :-
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Timer1.Tick
PictureBox1.Top = PictureBox1.Top - 1
PictureBox1.Left = PictureBox1.Left + 1
End Sub
End Sub
End Class
Output:-
-28
Program -WAP to change the back color of any control using scroll box.
sourceCode:
Public Class Form1
Dim r As Integer = 0
Dim g As Integer = 0
Dim b As Integer = 0
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
r = VScrollBar1.Value()
Me.BackColor = Color.FromArgb(r, g, b)
End Sub
End Sub
End Sub
End Class
Output :
Assignment -29
Assignment
sourceCode: Module
Module1
Sub Main()
Console.WriteLine("sherya thakur BCA 3rd year ")
Dim arr As Integer() = New Integer(5) {}
Dim item As Integer = 0
Dim flag As Integer = -1
Dim i As Integer = 0
Console.WriteLine("Enter array elements: ")
For i = 0 To 4 Step 1
Console.Write("Element[{0}]: ", i)
arr(i) = Integer.Parse(Console.ReadLine())
Next
Console.WriteLine("Enter item for searching: ")
item = Integer.Parse(Console.ReadLine())
For i = 0 To 4 Step 1
If item = arr(i) Then
flag = i
GoTo out
End If
Nextout:
If flag <> -1 Then
Console.WriteLine("Item found at index {0} in array", flag)
Else
Console.WriteLine("Item is not found")
End If
Console.ReadLine()
End Sub
End Module Output
:
– 30
Program-WAP to find greatest among three given number using user define
procedures. sourceCode:
Module Module1
Sub Main()
Console.WriteLine("sherya thakur BCA 3rd year ")
Dim result As Integer = 0
Dim num1 As Integer = 0
Dim num2 As Integer = 0
Dim num3 As Integer = 0
Console.Write("Enter number1: ")
num1 = Integer.Parse(Console.ReadLine())
Console.Write("Enter number2: ") num2 =
Integer.Parse(Console.ReadLine())
Console.Write("Enter number3: ") num3 =
Integer.Parse(Console.ReadLine()) result = If(
(num1 > num2 AndAlso num1 > num3), num1, If((num2 > num1 AndAlso num2 >
num3), num2, num3))
Console.WriteLine("GREATEST Number is: {0}", result)
Console.ReadLine()
End Sub
End Module Output
:
Assignment- 31
Program -wap a program to calculate factorial of a number using user
define procedures.
sourceCode:
Assignment
Module Module1
Sub Main()
Dim n, i, f As Integer
Console.Write("Enter a Number: ")
Console.WriteLine("Nikhil Jaiswal Bca 3rd year")
n = CInt(Console.ReadLine())
f=1
If n < 0 Then
Console.WriteLine("Factorial of negative number is possible")
ElseIf n = 0 Or n = 1 Then
Console.WriteLine("Factorial of " + n.ToString() + " is1")
Else
For i = 1 To n
f *= i
Next
Console.WriteLine("Factorial of " + n.ToString() + " is
+ f.ToString())
End If
Console.ReadLine()
End Sub
End Module
Output:-
Assignment- 32
Design the following application using radio button and checkbox :
Source code:-
Public Class Form1
Program:-
End If
End Sub
End Sub
End Sub
End Class
Output:-
Assignment -33
Design an application to create the payroll from shown below.
Number of hours must be entered as the appropriate rate.
Gross salary=rate*hours.
Net salary=gross salary-deduction.
Source code:-
Public Class Form1
If (RadioButton1.Checked) Then
TextBox4.Text = A * B
ElseIf (RadioButton2.Checked) Then
TextBox4.Text = A * B
Else
(RadioButton3.Checked) Then
TextBox4.Text = A * B
End If
TextBox5.Text = TextBox4.Text - C
End Sub
Program:-
End Class
Output:-
Assignment – 34
develop an application which is similar to note pad using menu
Step 3: Change the name of the form from its properties. This will be displayed on
the top of the Notepad as its heading.
From Toolbox, select menu strip and place it on the top in the form area. In MenuStrip,
you can provide the names of the various options that you want in your notepad. We are
adding File, Edit, and Format options in the menu. You can add more as per your choice.
Step 4: Now in the options provided in the MenuBar, we need to have a dialog
box that will open up as the user clicks on the File, Edit, or Font option. Therefore,
we will provide further options for them.
For FILE
Similarly, for Edit and Font, we will add the options as shown below: will add
options as follows:
Program:-
Assignment 35
Assignmen- 36
Program –Define structure student.struture student has data members for
storing name,roll no, name of three subject and marks.write member
funcation to store and print data. sourceCode:
Public Class Form1
Private Structure Student
Public Name As String
Public RollNo As Integer
Public Sub1 As String
Public Sub2 As String
Public Sub3 As String
Public Marks1 As Integer
Public Marks2 As Integer
Public Marks3 As Integer
End Structure
Dim Struct As Student
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Struct.Name = TextBox1.Text
Struct.RollNo = TextBox2.Text
Struct.Sub1 = TextBox3.Text
Struct.Sub1 = TextBox4.Text
Struct.Sub3 = TextBox5.Text
Struct.Marks1 = TextBox6.Text
Struct.Marks2 = TextBox7.Text
Struct.Marks3 = TextBox8.Text
Me.DataGridView1.Rows.Add(Struct.Name, Struct.RollNo, Struct.Sub1, Struct.Sub2, Struct.Sub3,
Struct.Marks1, Struct.Marks2, Struct.Marks3)
End Sub Endclass
Output:-
Assignment -37
Program-Write a class having name calculate that uses static overloaded funcation to
calculated area of circle,area of rectangle,,areaof triangle.
sourceCode: Module
Module1
Class geometry
Overloads Function area(ByVal r As Double)
Return 3.14 * r * r
End Function
Overloads Function area(ByVal l As Double, ByVal b As Double)
Return l * b
End Function
Overloads Function area(ByVal base As Integer, ByVal h As Integer)
Return (base * h) / 2
End Function
End Class
Sub Main()
Dim geo As geometry = New geometry
Console.WriteLine("Nikhil Jaiswal Bca 3rd year")
Console.WriteLine("Area of circle=" & geo.area(2.5))
Console.WriteLine("Area of rectangle=" & geo.area(2.5, 5.0))
Console.WriteLine("Area of triangle =" & geo.area(2, 5))
Console.ReadLine()
End Sub
End Module
Output:-
Assignment-38
Program : WAP to demonstrate concept of Polymorphism (function
Overloading and constructor Overloading).
Source code:
Module Module1
Class Sample
Private num As Integer
Public Sub New()
Console.WriteLine("Default or no argument constructor called to initialize data members")
num = 10
End Sub
Public Sub New(ByVal n As Integer)
Console.WriteLine("Parameterized constructor called to initialize data members")
num = n
End Sub
Public Sub Print()
Console.WriteLine("Value of num: {0}", num)
Console.ReadLine()
End Sub
End Class
Sub Main()
Dim obj1 As New Sample()
Dim obj2 As New Sample(20)
obj1.Print() obj2.Print()
End Sub
End Module
Funcation overloading :-
Module Module1
Class geometry
Overloads Function area(ByVal r As Double) As Integer
Return 3.14 * r * r
End Function
Overloads Function area(ByVal l As Double, ByVal b As Double) As Double
Return l * b
End Function
End Class
Sub Main()
Console.WriteLine("Name:Sherya Thakur")
Console.WriteLine("Class:- BCA 3rd Year")
Dim geo As geometry = New geometry()
Console.WriteLine("Area of circle =" & geo.area(2.5))
Console.WriteLine("Area of rect=" & geo.area(2.5, 5.0))
Console.ReadKey()
End Sub
End Module
Assignment 39
Program: WAP to display records of a tables using data adapter and code for
buttons to move at first record ,next record, previous record , last record in
the table.
Design Window:-
Table view:-
Source code :-
Public Class Form1
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Class
Output:-
Assignment 40
Program: Create a table for employee and write a program using dataset to
add , delete , edit & navigate records.
Form Design:
Source Code:
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\user\AppData\Local\Temporary Projects\Practicle\Practicle.accdb")
Dim ds As DataSet
Dim da As OleDbDataAdapter
Dim cmd As OleDbCommand
Dim count, maxRow As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
If con.State = ConnectionState.Closed Then
con.Open()
MsgBox("connected")
End If
End Sub
TextBox3.Text = ds.Tables(0).Rows(count).Item(2)
TextBox4.Text = ds.Tables(0).Rows(count).Item(3)
da.Dispose() ds.Dispose() End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
da = New OleDbDataAdapter("Select * from emp", con)
ds = New DataSet()
da.Fill(ds, "emp")
maxRow = ds.Tables(0).Rows.Count
count = count + 1
If count > maxRow - 1 Then
MsgBox("Last record")
Exit Sub
End If
TextBox1.Text = ds.Tables(0).Rows(count).Item(0)
TextBox2.Text = ds.Tables(0).Rows(count).Item(1)
TextBox3.Text = ds.Tables(0).Rows(count).Item(2)
TextBox4.Text = ds.Tables(0).Rows(count).Item(3)
da.Dispose()
ds.Dispose()
End Sub
da.Dispose()
ds.Dispose()
End Sub
Public Sub setDataToTextbox(ByVal sql As String)
da = New OleDbDataAdapter(sql, con)
ds = New DataSet()
da.Fill(ds, "emp") count
=0
TextBox1.Text = ds.Tables(0).Rows(count).Item(0)
TextBox2.Text = ds.Tables(0).Rows(count).Item(1)
TextBox3.Text = ds.Tables(0).Rows(count).Item(2)
TextBox4.Text = ds.Tables(0).Rows(count).Item(3)
da.Dispose()
ds.Dispose()
End Sub
End Class