Index: S NO. Topics No. Teacher Sign
Index: S NO. Topics No. Teacher Sign
Index: S NO. Topics No. Teacher Sign
1
8. Program to swap 2 numbers 20-21
using call by reference method.
2
16. Write a program to transfer 39-41
items from listbox to
combobox and vice versa
3
1. Program to show the use of inputbox and
messagebox to display the name
CODING :
End Sub
End Class
4
OUTPUT :
5
2. Program to accept a number an check whether it is
prime or not
CODING:
End Sub
End Class
6
Output :
7
3. Progrom to show largest in three numbers using
call by value
8
CODING :
Module largest
Public Function large(ByVal a As Integer, b As Integer, c As Integer)
Dim max As Integer
If a > b And a > c Then
max = a ElseIf b > c
Then max = b
Else max = c
End If
Return max
End Function
End Module
9
End Sub
End Class
OUTPUT :
10
Console.WriteLine(f)
f1 = f2 f2 = f
cnt += 1
End While
Console.ReadKey()
End Sub
End Module
11
5. Program to print factorial series
Module Factorial
Public Function fact(ByVal x As Integer) As Long
Dim i As Integer = 1
Dim f As Integer = 1
Do While (i <= x)
f *= i i += 1
Loop
Return f
End Function
End Module
12
6. Program To Find the Sum of Array elements
13
CODING:
Module Module1
Sub Main()
Dim n(5) As Integer
Dim s As Integer = 0
Console.WriteLine("Enter 5 Elements")
For i = 1 To 5
n(i) = CInt(Console.ReadLine())
Next i
Console.WriteLine("Array Elements are")
For i = 1 To 5
Console.WriteLine(n(i))
s = s + n(i)
Next i
Console.WriteLine("Sum of array elements=" & s)
Console.ReadLine()
End Sub
End Module
OUTPUT:
14
7. Program to show arraylist and its operations
CODING:
15
A.Insert(3, "BJMC")
TextBox1.Clear()
MsgBox("Item inserted successfully", , "Inserting an item ")
For i = 0 To A.Count - 1
TextBox1.Text = TextBox1.Text + " " + A.Item(i) + vbCrLf
Next
End Sub
16
17
18
19
8. Program to swap 2 numbers using call by reference method
CODING :
Module funcswap
Public Sub swap(ByRef x As Integer, ByRef y As Integer)
Dim t As Integer
t=x x=y
y=t
End Sub
End Module
20
OUTPUT:
21
CODING :
Public Class Form2
Dim st, rev As String
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
End
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click st =
TextBox1.Text rev =
Trim(StrReverse(st))
Label2.Text = rev
If String.Compare(st, rev, True) = 0 Then
MsgBox(st & " Is a Palindrome", , "To Check string")
Else
MsgBox(st & " Not a Palindrome", , "To Check string")
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
st = TextBox1.Text
MsgBox("Length of the string is " & st & " is " & Len(st), , "Find Length")
End Sub
Private Sub Label3_Click(sender As Object, e As EventArgs)
End Sub
End Class
22
OUTPUT:
23
CODING :
24
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
TextBox1.Text = Convert.ToString(TextBox1.Text) + Convert.ToString(5)
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles
Button6.Click
TextBox1.Text = Convert.ToString(TextBox1.Text) + Convert.ToString(6)
End Sub
25
result = temp1 / TextBox1.Text
TextBox1.Text = " "
TextBox1.Text = result
Else
result = temp1 * TextBox1.Text
TextBox1.Text = " "
TextBox1.Text = result
End If
End Sub
26
OUTPUT:
27
11. Program to illustrate the class
CODING :
Public Class Telephonebill
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim p As Long = CLng(TextBox1.Text)
Dim s As String = TextBox2.Text
Dim c As Integer = CInt(TextBox3.Text)
Dim a As Double
Dim ob1 As New telcall(p, s, c)
a = ob1.compute()
Label6.Text = a
End Sub
28
End
End Sub
End Class
Module Modcls
Public Class telcall
Dim phno As Long
Dim name As String
Dim n As Integer
Dim amt As Double
Public Sub New(ByVal p As Long, ByVal s As String, ByVal c As Integer)
phno = p name = s n=c amt = 0.0
End Sub
Public Function compute() As Double
If (n <= 100) Then
amt = 500
ElseIf (n <= 200) Then
amt = (n - 100) * 1.0 + 500
ElseIf (n <= 300) Then
amt = 100 * 1.0 + (n - 200) * 1.2 + 500
Else
amt = 100 * 1.0 + 100 * 1.2 + (n - 300) * 1.5 + 500
End If
Return amt
End Function
End Class End
Module
29
OUTPUT:
30
12. Program on overloaded methods -
Polymorphism
CODING:
31
Label2.Visible = True
Label3.Visible = True
ob1.area(5) ob1.area(6,
5) ob1.area(2.5)
End Sub
End Class
32
13. Program on Hierarchical Inheritance
Module module1
'Implementation of Hierarchical Inheritance
Public Class number
Dim num As Integer
Public Sub getnum()
Console.Write("Enter a number : ")
num = CInt(Console.ReadLine())
End Sub
Public Function retnum() As Integer
Return num
End Function
End Class
Public Class square
Inherits number
Public sqr, n1 As Integer
Public Function sqrnum(ByRef n1 As Integer) As Integer
sqr = n1 * n1 Return sqr
End Function
End Class
Public Class cube
Inherits number
Public cub, n2 As Double
Public Function cubnumber(ByRef n2 As Double) As Double
cub = n2 * n2 * n2
Return cub
End Function
End Class
Sub main()
Dim sobj As New square
Dim cuobj As New cube
Dim a As Integer
sobj.getnum() a=
sobj.retnum()
Console.WriteLine("Square of " & a & " is " & sobj.sqrnum(a))
Console.WriteLine(vbCrLf)
cuobj.getnum() a=
cuobj.retnum()
Console.WriteLine("Cube of " & a & " is " & cuobj.cubnumber(a))
Console.ReadKey()
End Sub
33
End Module
34
14. Program to show Implementation of Multi-level
Inheritance
Class BasketPlayer
Inherits Player
Public PointsPerGame As Double
Public Rebounds As Double
35
End Sub
36
15. Program to show Implementation of Multiple
Inheritance using Interface
Module Module2
'Implementation of Multiple Inheritance using Interface
Interface test
Function marks() As Integer
End Interface
Interface sports
Function grade_show(ByVal avg As Single) As Char
End Interface
Class result
Implements test
Implements sports
Public Function marks() As Integer Implements test.marks
Dim m1, m2, m3, m4, m5 As Integer
Dim avg As Single
Console.WriteLine("Enter the marks of five subjects")
m1 = CInt(Console.ReadLine()) m2 =
CInt(Console.ReadLine()) m3 =
CInt(Console.ReadLine()) m4 =
CInt(Console.ReadLine()) m5 =
CInt(Console.ReadLine()) avg = (m1 + m2 + m3 + m4 +
m5) / 5
Return avg
End Function
Public Function grade_show(ByVal avg As Single) As Char Implements sports.grade_show
Dim grade As Char
If avg >= 80 Then
grade = "A" ElseIf
avg >= 60 Then
grade = "B" ElseIf
avg >= 50 Then
grade = "C" Else
grade = "D"
End If
Return grade
End Function
End Class
Sub main()
Dim obj As New result()
Dim av As Single
Console.WriteLine("Implementation of Multiple Inheritance using Interface")
av = obj.marks() Console.WriteLine()
Console.WriteLine("Average Marks is " & av)
Console.WriteLine()
Console.WriteLine("Grade is " & obj.grade_show(av))
Console.ReadKey()
End Sub
End Module
37
38
16. Write a program to transfer items from listbox to
combobox and vice versa.
CODING:
Public Class Form1
Dim n As Integer
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles ListBox1.SelectedIndexChanged
' MsgBox(ListBox1.SelectedItem)
End Sub
End Sub
39
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ComboBox1.Items.Add(ListBox1.SelectedItem)
ComboBox1.Items.Remove(ComboBox1.Text)
End Sub
OUTPUT:
40
41
17. Program to display current date & time
CODING :
Public Class digitalclk
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
End
End Sub
OUTPUT:
42
18. Program on illustration of menustrip control
43
Public Class Form1
Dim t As String
Private Sub CUTToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
CUTToolStripMenuItem.Click
t = TextBox1.Text
TextBox1.Text = " "
End Sub
Private Sub COPYToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
COPYToolStripMenuItem.Click
t = TextBox1.Text
End Sub
Private Sub PASTERToolStripMenuItem_Click(sender As Object, e As EventArgs)
Handles PASTERToolStripMenuItem.Click
TextBox2.Text = t
End Sub
End Class
44
45
46
19. Program on illustration of listview control
CODING :
Public Class Form2
Dim arrproducts(4) As String
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs)
Handles RadioButton1.CheckedChanged
If RadioButton1.Enabled = True Then
ListView2.Visible = False
ListView3.Visible = False
ListView1.Visible = True
ListView1.View = View.List
End If
End Sub
Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs)
Handles RadioButton3.CheckedChanged
If RadioButton3.Enabled = True Then
ListView1.Visible = True
ListView3.Visible = False
ListView2.Visible = False
ListView1.View = View.Details
End If
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs)
Handles RadioButton2.CheckedChanged
If RadioButton2.Enabled = True Then
47
ListView1.Visible = False
ListView3.Visible = False
ListView2.Visible = True
For i = 0 To arrproducts.Length - 1
ListView2.Items.Add(arrproducts(i)) 'Add Each Item Of Array
ListView2.Items(i).ImageIndex = i 'Align ImageList Images With Array
Items
Next
End If
End Sub
48
OUTPUT:
49
50
51
20. Program on Exceptional Handling
CODING:
52
OUTPUT:
53
54
21. Program of accessing database using datagrid
OUTPUT:
55
22. Program to perform database
operations(add,delete,update) using ADO.net
Imports System.Data.OleDb
Public Class Form1
56
Public rno As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=F:\kiheat\New folder\clg.accdb")
con.Open()
Dim cmd As New OleDbCommand("insert into student values(" + TextBox1.Text +
",'" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "'," +
TextBox5.Text + ")", con) cmd.ExecuteNonQuery()
MsgBox("record added") con.Close() End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
End
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
flag()
rno = InputBox("Enter the rollno. to be deleted")
disp()
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=F:\kiheat\New folder\clg.accdb")
con.Open()
Dim cmd As New OleDbCommand("Delete from student where rollno=" + rno, con)
cmd.ExecuteNonQuery() MsgBox("Record DELETED") con.Close()
End Sub
57
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ClgDataSet.student' table. You can move,
or remove it, as needed.
Me.StudentTableAdapter.Fill(Me.ClgDataSet.student)
ListBox1.Enabled = False
End Sub
End Class
OUTPUTS :
58
DELETING RECORD FROM STUDENT TABLE
59
60
UPDATING RECORD IN A STUDENT TABLE
61
62