Gad Practical PDF
Gad Practical PDF
Class:
Namespace n1
Public Class Class1
Public Shared Sub d1()
Console.WriteLine("Hello World!")
End Sub
End Class
End Namespace
Module:
Imports [NameSpace]
Imports [NameSpace].n1
Module Program
Sub main()
Class1.d1()
Console.ReadLine()
End Sub
End Module
Class:
Namespace n1
Public Class Class1
Public Shared Sub d1()
Console.WriteLine("Hello World!")
End Sub
End Class
End Namespace
Module:
Imports [NameSpace]
Imports [NameSpace].n1
Module Program
Sub main()
Class1.d1()
Console.ReadLine()
End Sub
End Module
3. Implement a Message Box program & Arithmetic Expressions.
Module Program
Sub Main(args As String())
Dim a, b, c As Integer
a = InputBox("A =")
b = InputBox("B =")
c = a + b
Msgbox("C =" + c.ToString)
End Sub
End Module
Module Program
Imports System
Imports System.Transactions
Module Program
Sub Main(args As String())
Dim Ans As Integer
Console.WriteLine("1.ADDITION")
Console.WriteLine("2.SUBSTRACTION")
Console.WriteLine("Select Case :")
Ans = Console.ReadLine()
Select Case Ans
Case 1
Dim a, b, c As Integer
Console.WriteLine("Enter A =")
a = Console.ReadLine()
Console.WriteLine("Enter B =")
b = Console.ReadLine()
c = a + b
Console.WriteLine("C =" + c.ToString)
Console.ReadLine()
Case 2
Dim a, b, c As Integer
Console.WriteLine("Enter A =")
a = Console.ReadLine()
Console.WriteLine("Enter B =")
b = Console.ReadLine()
c = a - b
Console.WriteLine("C =" + c.ToString)
Console.ReadLine()
End Select
End Sub
End Module
(Do-While loop)
Module Program
Sub Main(args As String())
Dim n As Integer
n = 1
Do While n <= 10
Console.WriteLine(n)
n = n + 1
Loop
Console.ReadLine()
End Sub
End Module
(For-Each loop)
Module Program
Sub Main(args As String())
Dim Arr() As Integer = {10, 4, 6}
Dim n As Integer
For Each n In Arr
Console.WriteLine(n)
Next
Console.ReadLine()
End Sub
End Module
10. Design windows application using List Box & Combo Box.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Label1.Text = "Subject :" & ListBox1.SelectedItem &
"class :" & ComboBox1.SelectedItem
End Sub
End Class
End Sub
Module Program
Sub Main(args As String())
ADD(10, 20)
End Sub
Sub ADD(x As Integer, y As Integer)
Dim a, b, c As Integer
a = x
b = y
c = a + b
Console.WriteLine("Add =" + c.ToString)
End Sub
End Module
(default)
Imports System
Module Program
Sub Main(args As String())
ADD()
End Sub
Sub ADD()
Dim a, b, c As Integer
Console.WriteLine("A =")
a = Console.ReadLine()
Console.WriteLine("B =")
b = Console.ReadLine()
c = a + b
Console.WriteLine("Add =" + c.ToString)
End Sub
End Module
(default)
Imports System
Module Program
Function ADD()
Dim a, b, c As Integer
Console.WriteLine("A =")
a = Console.ReadLine()
Console.WriteLine("B =")
b = Console.ReadLine()
c = a + b
Console.WriteLine("Add =" + c.ToString)
End Function
(paramiterized)
Imports System
Module Program
Function ADD(x As Integer, y As Integer)
Dim a, b, c As Integer
a = x
b = y
c = a + b
Console.WriteLine("Add =" + c.ToString)
End Function
(class)
Public Class Class1
Public Sub Add()
Dim a, b, c As Integer
Console.WriteLine("A =")
a = Console.ReadLine()
Console.WriteLine("B =")
b = Console.ReadLine()
c = a + b
Console.WriteLine("Add =" + c.ToString)
End Sub
End Class
(module)
Module Program
Sub Main(args As String())
Dim obj = New Class1
obj.Add()
End Sub
End Module
End Class
(module)
Module Program
Sub Main(args As String())
Dim obj1 = New Class1
Console.ReadLine()
End Sub
End Module
(class)
Public Class Class1
Public Sub New()
Dim a, b As Integer
Console.WriteLine(" constructer Created ")
End Sub
Protected Overrides Sub finalize()
Console.WriteLine(" destroyed ")
End Sub
End Class
(module)
Imports System
Module Program
Sub Main(args As String())
Dim obj1 = New Class1()
End Sub
End Module
Imports System
Module Program
Public Class Class1
Dim no As Integer
Public Sub get1()
End Class
Module Program
Class class1
Dim a, b As Integer
Sub Add(x As Integer)
a = x
b = x
Console.WriteLine("Addition=" & (a + b))
End Sub
Sub Add(x As Integer, y As Integer)
a = x
b = y
Console.WriteLine("Addition=" & (a + b))
End Sub
End Class
Sub Main(args As String())
Dim obj1 = New class1()
obj1.Add(10)
obj1.Add(20, 30)
Console.ReadLine()
End Sub
End Module
Module Program
Class class1
Dim a, b As Integer
Overridable Sub Add(x As Integer, y As Integer)
a = x
b = y
Console.WriteLine("Addition=" & (a + b))
End Sub
End Class
Class class2 : Inherits class1
Dim a, b As Integer
Overrides Sub Add(x As Integer, y As Integer)
a = x
b = y
Console.WriteLine("Addition=" & (a + b))
End Sub
End Class
Sub Main(args As String())
Dim obj1 = New class2()
obj1.Add(10, 20)
obj1.Add(30, 40)
End Sub
End Module
Module Program
Class class1
Dim a, b As Integer
Sub Add(x As Integer, y As Integer)
a = x
b = y
Console.WriteLine("Addition=" & (a + b))
End Sub
End Class
Class class2 : Inherits class1
Dim a, b As Integer
Shadows Sub Add(x As Integer, y As Integer)
a = x
b = y
Console.WriteLine("Addition=" & (a + b))
End Sub
End Class
Module Program
Sub Main(args As String())
Dim a, b, c As Integer
Try
a = 8
b = 0
c = a \ b
Catch ex As DivideByZeroException
Console.WriteLine("DivideByZeroException has")
Console.WriteLine("result : {0}", c)
End Try
End Sub
End Module