Professional Documents
Culture Documents
Imports Sub Dim As New: Using Classes and Procedures
Imports Sub Dim As New: Using Classes and Procedures
Imports Sub Dim As New: Using Classes and Procedures
Imports System.Console
Module Module1
Sub Main()
Dim obj As New student()
obj.getentry()
obj.calculate()
obj.display()
Read()
End Sub
Public Class student
Dim r As Integer
Dim n As String
Dim m1,m2 As Integer
Dim tot As Integer
Dim avg As Double
Sub getentry()
Write("enter the regno")
r = Val(ReadLine())
Write("enter the name")
n = ReadLine()
Write("enter the mark1")
m1 = Val(ReadLine())
Write("enter the mark2")
m2 = Val(ReadLine())
End Sub
Sub calculate()
tot = m1 + m2
avg = tot / 2
End Sub
Sub display()
WriteLine("NAME:" & n)
WriteLine("REGNO:" & r)
WriteLine("MARK1:" & m1)
WriteLine("MARK2:" & m2)
WriteLine("TOTAL:" & tot)
WriteLine("AVERAGE:" & avg)
End Sub
End Class
End Module
USING ARRAYS
Imports System.Console
Module Module1
Sub Main()
Dim obj As New student()
Dim num As Integer
WriteLine("enter number of students")
num = Val(ReadLine())
obj.getentry(num)
obj.calculate()
obj.display()
Read()
End Sub
Public Class student
Dim r(10) As Integer
Dim n(10) As String
Dim m1(10), m2(10) As Integer
Dim tot(10) As Integer
Dim avg(10) As Double
Dim i As Integer
Dim nn As Integer
Sub getentry(ByVal nnn As Integer)
nn = nnn
For i = 0 To nn
WriteLine("enter the regno")
r(i) = Val(ReadLine())
WriteLine("enter the name")
n(i) = ReadLine()
WriteLine("enter the mark1")
m1(i) = Val(ReadLine())
WriteLine("enter the mark2")
m2(i) = Val(ReadLine())
Next i
End Sub
Sub calculate()
For i = 0 To nn
End Module
USING STRUCTURES AND FUNCTIONS
Imports System.Console
Module Module1
Structure product
Dim pno As Integer
Dim pname As String
Dim qty As Integer
Dim cost As Integer
Public Function calculate(ByVal pno, ByVal
pname, ByVal qty) As Integer
If (pname = "soap") Then
Return (26 * qty)
Else
Return (0)
End If
End Function
End Structure
Sub Main()
Dim p As New product()
Dim n As Integer
WriteLine("enter the product no:")
p.pno = Val(ReadLine())
WriteLine("enter the product name:")
p.pname = ReadLine()
WriteLine("enter the product quantity:")
p.qty = Val(ReadLine())
n = p.calculate(p.pno, p.pname, p.qty)
WriteLine("Amount" & n)
Read()
End Sub
End Module
USING STRUCTURE, FUNCTION AND ARRAYS
Imports System.Console
Module Module1
Public pno(,) As Integer
Public pname() As String
Structure product
Dim i As Integer
Dim j As Integer
Next i
Next j
Return (u.amt)
End Function
Sub Main()
Dim i, j As Integer
Dim n, tot As Integer
Dim p As New product()
pname = New String() {"soap", "horlicks",
"biscut"}
pno = New Integer(,) {{1, 23}, {2, 90}, {3,
12}}
WriteLine("--------------------------")
WriteLine("KANNAN DEPARTMENTAL STORE")
WriteLine("--------------------------")
WriteLine("PNO COST PNAME")
WriteLine("--------------------------")
For i = 0 To 2
For j = 0 To 1
Write(" " & pno(i, j))
Write(" ")
Next j
WriteLine(" " & pname(i))
Next i
WriteLine("--------------------------")
WriteLine("ENTER THE NO.OF.PRODUCTS")
n = Val(ReadLine())
tot = calculate(n)
MsgBox("u need to pay" & tot)
Read()
End Sub
End Module
ABSTRACT CLASS
Imports System.Console
Module Module1
Public MustInherit Class AbstractClass
Public MustOverride Function Add()
Public MustOverride Function Mul()
End Class
End Function
End Class
Sub Main()
Dim abs As New absone
WriteLine("sum is" & abs.Add())
WriteLine("multiplication is" & abs.Mul())
Read()
End Sub
End Module
Sub Main()
End Class
Public Class payroll
Inherits employee
Dim h, d As Double
Dim p, i, gp, np As Double
Public test As Integer = 16000
Public Function calculate1()
h = manager * 0.04
d = manager * 0.03
p = manager * 0.01
i = manager * 0.01
gp = (manager + h + d)
np = gp - (p + i)
Return (np)
End Function
Public Function calculate2()
Return (program())
End Function
End Class
End Module
OVERRIDING CONCEPT
Imports System.Console
Module Module3
Sub main()
Dim abs As New calculate1()
Dim a As Integer
Dim b As Integer
Dim n As Integer
WriteLine("choose ur category to purchase1.gold
2.silver")
n = Val(ReadLine())
If (n = 1) Then
WriteLine("Enter the no.of.grams")
a = Val(ReadLine())
WriteLine("total amount:" &
abs.goldrate(a))
Else
WriteLine("Enter the no.of.grams")
b = Val(ReadLine())
WriteLine("total amount:" & abs.silver(b))
End If
Read()
End Sub
Public MustInherit Class AbstractClass
Public MustOverride Function goldrate(ByVal a)
Public MustOverride Function silver(ByVal b)
Public g As Double = 1502.22
Public s As Double = 45.67
End Class
End Module
STUDENT AND EMPLOYEE CALCULATION USING INTERFACE
Imports System.Console
Module Module5
Sub main()
Dim st As New student()
Dim e As New employee()
Dim v As Integer
WriteLine("enter 1.student details
2.employee")
v = Val(ReadLine())
If (v = 1) Then
st.getentry()
st.calculate()
Else
e.getentry()
e.calculate()
End If
Read()
End Sub
Public Interface test
Sub getentry()
Function calculate()
End Interface
Public Class student
Implements test
Dim s1 As String
Dim m1, m2, tot As Integer
Sub getentry() Implements test.getentry
WriteLine("enter the name")
s1 = ReadLine()
WriteLine("enter the mark1")
m1 = Val(ReadLine())
WriteLine("enter the mark2")
m2 = Val(ReadLine())
End Sub
Public Function calculate() Implements
test.calculate
tot = m1 + m2
WriteLine("Total" & tot)
Return (0)
End Function
End Class
Public Class employee
Implements test
Dim nam As String
Dim b, a, amt As Double
Public Function calculate() As Object
Implements test.calculate
amt = b + a
WriteLine("salary" & amt)
Return (0)
End Function
Sub Main()
Dim dlg As mydelegate
dlg = New mydelegate(AddressOf msg)
dlg.Invoke()
Dim dlg1 As mydelegate1
dlg1 = New mydelegate1(AddressOf sqrt)
dlg1.Invoke(10)
Console.Read()
End Sub
End Module
Threads:
Imports System.Threading
Module Module1
Sub Main()
Dim t As New Thread(AddressOf print)
t.Start()
Console.Read()
End Sub
Sub print()
Console.WriteLine("Program using
thread")
End Sub
End Module