0% found this document useful (0 votes)
37 views63 pages

Visual Basic Console Examples

The document contains code snippets demonstrating the use of various programming concepts in VB.NET including modules, variables, input/output, conditional statements like If/Else and Select Case, and loops like While, Do While, For Each. The code shows how to write simple programs that take user input, perform calculations, and output results with conditional logic and iterative processing.

Uploaded by

wasim ahmed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views63 pages

Visual Basic Console Examples

The document contains code snippets demonstrating the use of various programming concepts in VB.NET including modules, variables, input/output, conditional statements like If/Else and Select Case, and loops like While, Do While, For Each. The code shows how to write simple programs that take user input, perform calculations, and output results with conditional logic and iterative processing.

Uploaded by

wasim ahmed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1)

Module Module1
Sub Main()
[Link]("Welcome to [Link] ")
[Link]()
End Sub
End Module
2)
Module Module1
Sub Main()
[Link]("Welcome to [Link] ")
[Link]("Thank you")
[Link]()
End Sub
End Module
3)
Module Module1
Sub Main()
Dim n As Integer
n = 10
[Link]("n")
[Link](n)
[Link]("Value of N is " & n)
[Link]()
End Sub
End Module
4)
Module Module1
Sub Main()
Dim n As Integer
[Link]("Enter N Value ")
n = [Link]()
[Link]("Value of N is " & n)
[Link]()
End Sub
End Module

5)
Module Module1
Sub Main()
Dim a, b, c As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a + b
[Link]("C")
[Link](c)
[Link]("Sum of A and B is " & c)
[Link]("sum of " & a & " and " & b & " is " & c)
[Link]("Sum of {0} and {1} is {2} ", a, b, c)

[Link]()
End Sub
End Module
6)
Module Module1
Sub Main()
Dim a, b As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
[Link]("Sum
[Link]("Sub
[Link]("Mul
[Link]("Rem
[Link]("Cos
[Link]("Cos

[Link]()
End Sub
End Module
7)

of A
of A
of A
of A
/ of
\ of

and B
and B
and B
and B
A and
A and

is "
is "
is "
is "
B is
B is

&
&
&
&
"
"

a
a
a
a
&
&

+ b)
- b)
* b)
Mod b)
a / b)
a \ b)

Module Module1
Sub Main()
Dim sno, m1, m2, tot As Integer
Dim sname As String
Dim avg As Single
[Link]("Enter Student Number
sno = [Link]
[Link]("Enter Student Name
sname = [Link]
[Link]("Enter Marks in Paper
m1 = [Link]
[Link]("Enter Marks in Paper
m2 = [Link]

")
")
I ")
II ")

tot = m1 + m2
avg = tot / 2
[Link]("Total Marks
" & tot)
[Link]("Average Marks " & avg)
[Link]()
End Sub
End Module
Conditonal Statmetns
======================
Simple if
-------------if <condi> then
<Statements>
End if
if ... else
----------if <condi> then
<Statements>
else
<Statements>
End if
elseif
--------if <condi> then
<Statements>
elseif <condi> then
<Statements>
. . . .
[ else
<Statements> ]
End if

Nested if
------------if <condi> then
<Statements>
if <condi> then
<Statmetns>
else
<Statements>
End if
else
<Statements>
End if
1)
Module Module1
Sub Main()
Dim a, b As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
If a > b Then
[Link]("A is Big")
End If
[Link]()
End Sub
End Module
2)
Module Module1
Sub Main()
Dim a, b As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
If a > b Then
[Link]("A is Big")
Else
[Link]("B is Big")
End If
[Link]()
End Sub

End Module
3)
Module Module1
Sub Main()
Dim a, b As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]

If a = b Then
[Link]("Both are Equal ")
Else
[Link]("Both are Not equal")
End If
[Link]()
End Sub
End Module
4)
Module Module1
Sub Main()
Dim a, b, c As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
[Link]("Enter Value of C ")
c = [Link]

If (a = b) And b = c Then
[Link]("All are Equal ")
Else
[Link]("Not equal")
End If
[Link]()
End Sub
End Module
5)
Module Module1
Sub Main()

Dim a, b, c As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
[Link]("Enter Value of C ")
c = [Link]

If (a = b) Or b = c Or c = a Then
[Link]("Two Values are Equal ")
Else
[Link]("Not equal")
End If
[Link]()
End Sub
End Module
6)
Module Module1
Sub Main()
Dim a, b As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
If a > b Then
[Link]("A is Big")
ElseIf b > a Then
[Link]("B is Big")
Else
[Link]("Both are Equal")
End If
[Link]()
End Sub
End Module
7)
Module Module1
Sub Main()
Dim sno, m1, m2, tot As Integer
Dim sname, res, div As String
Dim avg As Single
[Link]("Enter Student Number ")
sno = [Link]
[Link]("Enter Student Name ")
sname = [Link]

[Link]("Enter Marks in Paper I ")


m1 = [Link]
[Link]("Enter Marks in Paper II ")
m2 = [Link]
tot = m1 + m2
avg = tot / 2
If m1 >= 35 And m2 >= 35 Then
res = "Pass"
If avg >= 60 Then
div = "First"
ElseIf avg >= 50 Then
div = "Second"
Else
div = "Third"
End If
Else
res = "Fail"
div = "No div"
End If
[Link]("Total Marks
[Link]("Average Marks
[Link]("Result
[Link]("Division

"
"
"
"

&
&
&
&

tot)
avg)
res)
div)

[Link]()
End Sub
End Module

=============================================================
Select Case
================
select case <expr>
case <expr>
<Statmetns>
case <expr>
<Statmetns>
case <expr>
<Statmetns>
.....
[ case else
<Statements> ]
End Select
1)
Module Module1
Sub Main()

Dim n As Integer
[Link]("Enter Any Value between 1 to 5 ")
n = [Link]
Select Case n
Case 1
[Link]("One")
Case 2
[Link]("Two")
Case 3
[Link]("Three")
Case 4
[Link]("Four")
Case 5
[Link]("Five")
Case Else
[Link]("Out of Range ")
End Select
[Link]()
End Sub
End Module

2)
Module Module1
Sub Main()
Dim n As Integer
[Link]("Enter Any Value between 1 to 10 ")
n = [Link]
Select Case n
Case 1 To 10
[Link]("With in a Range")
Case Else
[Link]("Out of Range ")
End Select
[Link]()
End Sub
End Module

3)
Module Module1
Sub Main()

Dim n As Integer
[Link]("Enter Any Value between 1 to 10 ")
n = [Link]
Select Case n
Case 2, 5, 8, 10
[Link]("With in a List")
Case Else
[Link]("Out of List ")
End Select
[Link]()
End Sub
End Module

4)
Module Module1
Sub Main()
Dim st As String
[Link]("Enter Course ")
st = [Link]
Select Case st
Case "dca"
[Link]("Course
Case "pgdca"
[Link]("Course
Case "dtp"
[Link]("Course
Case Else
[Link]("Course
End Select

is Available ")
is Available ")
is Available ")
is not Available ")

[Link]()
End Sub
End Module

5)
Module Module1
Sub Main()
Dim st As String
[Link]("Enter Course ")
st = [Link]
Select Case st
Case "dca", "pgdca", "dtp"
[Link]("Course is Available")

Case Else
[Link]("Course is not Available ")
End Select
[Link]()
End Sub
End Module

6)
Module Module1
Sub Main()
Dim avg As Single
[Link]("Enter Average Marks ")
avg = [Link]
Select Case avg
Case Is >= 60
[Link]("First Class ")
Case Is >= 50
[Link]("Second Class ")
Case Is >= 35
[Link]("Third Class ")
Case Else
[Link]("No div")
End Select
[Link]()
End Sub
End Module

loops
========
while

do ..loops

for

=========================================================
while loop
---------------while <expr>
<Statments>
End While
1)
Module Module1
Sub Main()

Dim i As Integer
While i <= 10
[Link]("Welcome")
i = i + 1
End While
[Link]()
End Sub
End Module

2)
Module Module1
Sub Main()
Dim i As Integer
i = 1
While i <= 10
[Link](i & Space(5))
i = i + 1
End While
[Link]()
End Sub
End Module

3)
Module Module1
Sub Main()
Dim i, n As Integer
[Link]("Enter N Value ")
n = [Link]
i = 1
While i <= n
If i Mod 2 = 0 Then
[Link](i & Space(5))
End If
i = i + 1
End While
[Link]()
End Sub
End Module

4)
prime Number
---------7 3

Module Module1
Sub Main()
Dim i, n, c As Integer
[Link]("Enter N Value ")
n = [Link]
i = 1
While i <= n
If n Mod i = 0 Then
c = c + 1
End If
i = i + 1
End While
If c = 2 Then
[Link]("It is Prime Number ")
Else
[Link]("It is not a Prime Number ")
End If
[Link]()
End Sub
End Module

8)
perfact
Module Module1
Sub Main()
Dim i, n, s As Integer
[Link]("Enter N Value ")
n = [Link]
i = 1
While i < n
If n Mod i = 0 Then
s = s + i
End If
i = i + 1
End While
If s = n Then
[Link]("It is Perfact Number ")
Else
[Link]("It is not a Perfact Number ")
End If
[Link]()
End Sub
End Module

do....loops
==============
do while/until <expr>
<Statmets>
[ exit do]
<Stamtents>
loop
1)
Module Module1
Sub Main()
Dim i As Integer
i = 1
Do While i <= 10
[Link](i & Space(5))
i = i + 1
Loop
[Link]()
End Sub
End Module
2)
Module Module1
Sub Main()
Dim i As Integer
i = 1
Do While i <= 10
[Link](i & Space(5))
i = i + 1
If i > 5 Then
Exit Do
End If
Loop
[Link]()
End Sub
End Module

3)
Module Module1
Sub Main()
Dim i As Integer
i = 1

Do While i <= 10
[Link]((i) & Space(5))
i = i + 1
If i > 5 Then
Exit Do
End If
Loop
[Link]()
End Sub
End Module

4)
Module Module1
Sub Main()
Dim i As Integer
i = 1
Do Until i > 10
[Link]((i) & Space(5))
i = i + 1
Loop
[Link]()
End Sub
End Module

do
<statemetns>
[ exit do]
<Statments>
loop while/until <expr>
1)
Module Module1
Sub Main()
Dim i As Integer
i = 1
Do
[Link]((i) & Space(5))
i = i + 1
Loop While i <= 10
[Link]()
End Sub
End Module

2)
Module Module1
Sub Main()
Dim i As Integer
i = 1
Do
[Link]((i) & Space(5))
i = i + 1
Loop While i > 10
[Link]()
End Sub
End Module

3)
Module Module1
Sub Main()
Dim i As Integer
i = 1
Do
[Link]((i) & Space(5))
i = i + 1
Loop Until i > 10
[Link]()
End Sub
End Module

4)
Module Module1
Sub Main()
Dim i As Integer
i = 1
Do
[Link]((i) & Space(5))
i = i + 1
If i > 5 Then
Exit Do
End If
Loop Until i > 10
[Link]()
End Sub

End Module

for loop
=======
For <Var> As <Data type> = <Start Value > to <End Value> [ step value]
<Statmetns>
[ Exit for ]
<Statements>
Next
1)
Module Module1
Sub Main()
For i As Integer = 1 To 10 Step 1
[Link](i & Space(5))
Next
[Link]()
End Sub
End Module
2)
Module Module1
Sub Main()
Dim i As Integer
For i = 1 To 10
[Link](i & Space(5))
Next
[Link]()
End Sub
End Module

3)
Module Module1
Sub Main()
Dim i As Integer
For i = 1 To 10 Step 2
[Link](i & Space(5))

Next
[Link]()
End Sub
End Module

4)
Module Module1
Sub Main()
Dim i As Integer
For i = 10 To 1 Step -1
[Link](i & Space(5))
Next
[Link]()
End Sub
End Module

5)
Module Module1
Sub Main()
Dim i, n As Integer
[Link]("Enter Table Number ")
n = [Link]
For i = 1 To 20
[Link](n & "
Next
[Link]()
End Sub

End Module

========================================
array function
============
1)
Module Module1
Sub Main()
Dim a(5) As Integer

" & i & " = " & n * i)

Dim i As Integer
[Link](" Array Lenght " & [Link])
[Link](" Starting Index " & [Link](0))
[Link](" Ending Index " & [Link](0))
For i = 0 To 5
[Link]("Enter any Value ")
a(i) = [Link]()
Next
For i = [Link](0) To [Link](0)
[Link](a(i) & Space(5))
Next
[Link]()
End Sub

End Module

2)
Module Module1
Sub Main()
Dim a(5) As Integer
Dim i As Integer
For i = 0 To 5
[Link]("Enter any Value ")
a(i) = [Link]()
Next
For i = [Link](0) To [Link](0)
[Link](a(i) & Space(5))
Next
[Link](a)
[Link]()
[Link]("After Sorting ")
For i = [Link](0) To [Link](0)
[Link](a(i) & Space(5))
Next
[Link]()
End Sub

End Module

3)
Module Module1
Sub Main()
Dim a(5) As Integer
Dim i As Integer
For i = 0 To 5
[Link]("Enter any Value ")
a(i) = [Link]()
Next
For i = [Link](0) To [Link](0)
[Link](a(i) & Space(5))
Next
[Link](a)
[Link]()
[Link]("After Sorting ")
For i = [Link](0) To [Link](0)
[Link](a(i) & Space(5))
Next
[Link]()
End Sub

End Module

4)
Module Module1
Sub Main()
Dim a(5) As Integer
Dim i, ser, x As Integer
For i = 0 To 5
[Link]("Enter any Value ")
a(i) = [Link]()
Next
For i = [Link](0) To [Link](0)
[Link](a(i) & Space(5))
Next

[Link]()
[Link]("Enter Value for Search ")
ser = [Link]
x = [Link](a, ser)
If (x < 0) Then
[Link](ser & " Vlaue is Not Found ")
Else
[Link](ser & " Value is Found at " & x & " Location ")
End If

[Link]()
End Sub

End Module

5)
Module Module1
Sub Main()
Dim a(5) As Integer
Dim b(10) As Integer
Dim i As Integer
For i = 0 To 5
[Link]("Enter any Value ")
a(i) = [Link]()
Next
For i = [Link](0) To [Link](0)
[Link](a(i) & Space(5))
Next
'[Link](a, b, 3)
[Link](a, 2, b, 5, 2)
[Link]()
[Link]("B Array ")
For i = [Link](0) To [Link](0)
[Link](b(i) & Space(5))
Next

[Link]()
End Sub

End Module
=========================================================
Functions
==========
public/private Function <Fun name>([ Argu List]) As <Return Type>
<Statements>
[ Exit Function ]
<Statements>
End Function

1)
Module Module1
Public Function sum(ByVal a As Integer, ByVal b As Integer) As Integer
Dim c As Integer
c = a + b
Return c
End Function
Sub Main()
Dim a, b, c As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = sum(a, b)
[Link]("Sum of A and B is

" & c)

[Link]()
End Sub

End Module

2) Function Overloading
Module Module1
Public Function sum(ByVal a As Integer, ByVal b As Integer) As Integer

Dim c As Integer
c = a + b
Return c
End Function
Public Function sum(ByVal a As Single, ByVal b As Single) As Single
Dim c As Single
c = a + b
Return c
End Function
Sub Main()
Dim a, b, c As Integer
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = sum(a, b)
[Link]("Sum of A and B is

" & c)

[Link]()
End Sub

End Module

3)
Module Module1
Sub Main()
Dim n, f As Integer
[Link]("Enter Any Value ")
n = [Link]
f = fact(n)
[Link](n & " Fact is

" & f)

[Link]()
End Sub
Public Function fact(ByVal n As Integer) As Integer
Dim f, i As Integer
f = 1
For i = 1 To n
f = f * i
Next
Return f

End Function

End Module

3)
Module Module1
Sub Main()
Dim n As Integer
Dim r As Boolean
[Link]("Enter Any Value ")
n = [Link]
r = arm(n)
If r = True Then
[Link]("It is Armstrong ")
Else
[Link]("It is NOt an Armstong ")
End If
[Link]()
End Sub
Public Function arm(ByVal n As Integer) As Boolean
Dim d, r, t As Integer
t = n
While n > 0
d = n Mod 10
r = r + (d * d * d)
n = Int(n / 10)
End While
If t = r Then
Return True
Else
Return False
End If
End Function

End Module

Procedures
===========

public/private

sub <sub Name>( [ Argu List])

<Statements>
[ Exit Sub ]
<Statmetns>
End Sub

1)
Module Module1
Public Sub disp(ByVal st As String)
[Link](st)
End Sub
Sub Main()
disp("Welcome")
disp("BDPS")
disp("Thank You")
[Link]()
End Sub

End Module

2) Call by Value
Module Module1
Public Sub swap(ByVal a As Integer, ByVal b As Integer)
Dim t As Integer
t = a
a = b
b = t
End Sub
Sub Main()
Dim a, b As Integer
a = 10
b = 20
[Link]("Value of A is " & a)
[Link]("Value of B is " & b)
swap(a, b)
[Link]("After Swaping ")
[Link]("Value of A is " & a)
[Link]("Value of B is " & b)
[Link]()
End Sub

End Module

3) Call by Referance
Module Module1
Public Sub swap(ByRef a As Integer, ByRef b As Integer)
Dim t As Integer
t = a
a = b
b = t
End Sub
Sub Main()
Dim a, b As Integer
a = 10
b = 20
[Link]("Value of A is " & a)
[Link]("Value of B is " & b)
swap(a, b)
[Link]("After Swaping ")
[Link]("Value of A is " & a)
[Link]("Value of B is " & b)
[Link]()
End Sub

End Module

=========================================================
String Functions
================
1) Trim Functions
===============
Module Module1
Sub Main()
Dim st1, st2 As String
st1 = "
WELCOME
st2 = "BDPS"

"

[Link](st1 + st2)
[Link](LTrim(st1) + st2)
[Link](RTrim(st1) + st2)
[Link](Trim(st1) + st2)

[Link]()
End Sub
End Module

Case Converseion
===============
Module Module1
Sub Main()
Dim st1, st2 As String
st1 = "welcome"
st2 = "BDPS"
'[Link](UCase(st1))
'[Link](LCase(st2))
[Link]([Link])
[Link]([Link])
[Link]()
End Sub
End Module
3)
Module Module1
Sub Main()
Dim st As String
st = "welcome"
[Link](st)
[Link](Left(st, 3))
[Link](Right(st, 4))
[Link](Mid(st, 3))
[Link](Mid(st, 3, 3))
[Link]()
End Sub
End Module

4)
BDPS
B
BD
BDP
BDPS

Module Module1
Sub Main()
Dim st As String
Dim i As Integer
[Link]("Enter Any String ")
st = [Link]
For i = 1 To [Link]
[Link](Left(st, i))
Next
[Link]()
End Sub
End Module

5)
BDPS
B
D
P
S
Module Module1
Sub Main()
Dim st As String
Dim i As Integer
[Link]("Enter Any String ")
st = [Link]
For i = 1 To [Link]
[Link](Mid(st, i, 1))
Next
[Link]()
End Sub
End Module

5)
BDPS
S
PS
DPS
BDPS
Module Module1
Sub Main()

Dim st As String
Dim i As Integer
[Link]("Enter Any String ")
st = [Link]
For i = 1 To [Link]
[Link](Right(st, i))
Next
[Link]()
End Sub
End Module

6)
BDPS
S
SP
SPD
SPDB
Module Module1
Sub Main()
Dim st, st1 As String
Dim i, L As Integer
[Link]("Enter Any String ")
st = [Link]
st1 = " "
L = [Link]
For i = 1 To [Link]
st1 = st1 + Mid(st, L, 1)
L = L - 1
[Link](Right(st1, i))
Next
[Link]()
End Sub
End Module

7) Reverse String
Module Module1
Sub Main()
Dim st, st1 As String
Dim i, L As Integer
[Link]("Enter Any String ")
st = [Link]
st1 = " "

L = [Link]
For i = 1 To [Link]
st1 = st1 + Mid(st, L, 1)
L = L - 1
Next
[Link](Right(st1, i))
[Link]()
End Sub
End Module

8) Palandrom string
Module Module1
Sub Main()
Dim st, st1 As String
Dim i, L As Integer
[Link]("Enter Any String ")
st = [Link]
st1 = " "
L = [Link]
For i = 1 To [Link]
st1 = st1 + Mid(st, L, 1)
L = L - 1
Next
If Trim(st1).ToUpper = Trim(st).ToUpper Then
[Link]("It is Palandrom ")
Else
[Link]("It is not a Palanrom ")
End If
[Link]()
End Sub
End Module

==========================================================
Number Functions
=================
Module Module1
Sub Main()
[Link]([Link](-12))
[Link]([Link](10, 20))
[Link]([Link](10, 222))
[Link]([Link](10, 2))
[Link]([Link](10.9))
[Link]([Link](10.1))
[Link]([Link](10.5))
[Link]([Link](10.6))
[Link]([Link](20))

[Link]([Link](0))
[Link]([Link](0))
[Link]([Link](10))
[Link]()
End Sub
End Module

Date and Time Functions


=====================
Module Module1
Sub Main()
[Link](Now)
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]([Link])

[Link]()
End Sub
End Module

2)
Module Module1
Sub Main()
[Link](Now)
[Link]([Link](10))
[Link]([Link](5))
[Link]([Link](5))
[Link]([Link](10))
[Link]([Link](5))
[Link]()
End Sub
End Module

3)
Module Module1
Sub Main()

[Link](Format([Link],
[Link](Format([Link],
[Link](Format([Link],
[Link](Format([Link],

"d-MM-yy"))
"dd-MM-yy"))
"ddd-MM-yy"))
"dddd-MM-yy"))

[Link](Format([Link], "dd-MMM-yy"))
[Link](Format([Link], "dd-MMMM-yy"))
[Link](Format([Link], "dd-MM-yyyy"))
[Link]([Link])
[Link](Format([Link], "dddd, MMM dd, yyyy"))
[Link]()
End Sub
End Module

4)
Module Module1
Sub Main()
Dim d1, d2 As Date
d1 = [Link]
d2 = "10-10-2000"
[Link](DateDiff([Link], d2, d1))
[Link](DateDiff([Link], d2, d1))
[Link](DateDiff([Link], d2, d1))
[Link](DateDiff([Link], d2, d1))
[Link](DateDiff([Link], d2, d1))
[Link](DateDiff([Link], d2, d1))
[Link]()
End Sub
End Module

ooops
=====
1)
Module Module1
Class Emp
Public eno As Integer
Public ename As String
Public esal As Single
End Class
Sub Main()
Dim e As New Emp
[Link] = 111
[Link] = "Nikil"
[Link] = 10000

[Link]("EMP NUMBER
[Link]("EMP NAME
[Link]("EMP SALARY

" & [Link])


" & [Link])
" & [Link])

[Link]()
End Sub
End Module

2)
Module Module1
Class Emp
Private eno As Integer
Private ename As String
Private esal As Single
Public Sub getEmp()
[Link]("Enter Emp Number
eno = [Link]
[Link]("Enter Emp Name
ename = [Link]
[Link]("Enter Emp Salary
esal = [Link]
End Sub
Public Sub dispEmp()
[Link]("EMP NUMBER
[Link]("EMP NAME
[Link]("EMP SALARY
End Sub
End Class
Sub Main()
Dim e As New Emp
[Link]()
[Link]()
[Link]()
End Sub
End Module

3)
Module Module1
Class Emp
Public eno As Integer
Public ename As String
Private eage As Integer
Private esal As Single

")
")
")

" & eno)


" & ename)
" & esal)

Public Sub
eage =
End Sub
Public Sub
esal =
End Sub

empAge(ByVal age As Integer)


age
empSal(ByVal sal As Single)
sal

Public Sub dispEmp()


[Link]("EMP
[Link]("EMP
[Link]("EMP
[Link]("EMP

NUMBER
NAME
AGE
SALARY

"
"
"
"

&
&
&
&

eno)
ename)
eage)
esal)

End Sub
End Class
Sub Main()
Dim e As New Emp
[Link] = 111
[Link] = "Nikil"
[Link](20)
[Link](20000)

[Link]()
[Link]()
End Sub
End Module

4) Passing the Objects as a Argumnets


Module Module1
Class Test
Private n As Integer
Public Sub getData()
[Link]("Enter Number ")
n = [Link]
End Sub
Public Sub dispData()
[Link]("Value of N is " & n)
End Sub
Public Sub sum(ByVal t1 As Test, ByVal t2 As Test)
n = t1.n + t2.n
End Sub
End Class
Sub Main()
Dim t1 As New Test

Dim t2 As New Test


Dim t3 As New Test
[Link]()
[Link]()
[Link]()
[Link]()
[Link](t1, t2)
[Link]()

[Link]()
End Sub
End Module
5) Passing and Returning the Objects
Module Module1
Class Test
Private n As Integer
Public Sub getData()
[Link]("Enter Number ")
n = [Link]
End Sub
Public Sub dispData()
[Link]("Value of N is " & n)
End Sub
Public Function sum(ByVal t2 As Test) As Test
Dim t3 As New Test
t3.n = n + t2.n
Return t3
End Function
End Class
Sub Main()
Dim t1 As New Test
Dim t2 As New Test
Dim t3 As New Test
[Link]()
[Link]()
[Link]()
[Link]()
t3 = [Link](t2)

[Link]()

[Link]()
End Sub
End Module

=============================================================
Constructors
===============
It is a Method, but is a special Mehtod because it has some special chararcter
s :
->
The Constructr Name is NEW
Keyword
->
It must be Procedure ( SUB)
->
It must be in Public by default it is in ublic
- >
The arguments are optional
->
It excutes automatically when we allocate the memory to thte Object.
Note : The Constructor usually used for Initialiation purpose
1)
Module Module1
Class Demo
Public n As Integer
Sub New()
n = 100
[Link]("Value of N is " & n)
End Sub
End Class
Sub Main()
Dim d As New Demo
[Link]()
End Sub
End Module

2)
Module Module1
Class Emp
Private eno As Integer
Private ename As String
Private esal As Single
Sub New()

eno = 111
ename = "aaa"
esal = 10000
End Sub
Public Sub empData()
[Link]("Emp Number
[Link]("Emp Name
[Link]("Emp Salary
End Sub
End Class
Sub Main()

" & eno)


" & ename)
" & esal)

Dim e As New Emp


[Link]()
[Link]()
End Sub
End Module

3)
Module Module1
Class Emp
Private eno As Integer
Private ename As String
Private esal As Single
Sub New(ByVal no As Integer, ByVal
eno = no
ename = name
esal = sal
End Sub
Public Sub empData()
[Link]("Emp Number
[Link]("Emp Name
[Link]("Emp Salary
End Sub
End Class
Sub Main()

name As String, ByVal sal As Single)

Dim e1 As New Emp(111, "aaa", 10000)


Dim e2 As New Emp(222, "bbb", 20000)
Dim e3 As New Emp(333, "ccc", 30000)

" & eno)


" & ename)
" & esal)

[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Module

4)
Module Module1

Class Emp
Private eno As Integer
Private ename As String
Private esal As Single
Sub New(ByVal eno As Integer, ByVal ename As String, ByVal esal As Singl
e)
[Link] = eno
[Link] = ename
[Link] = esal
End Sub
Public Sub empData()
[Link]("Emp Number
[Link]("Emp Name
[Link]("Emp Salary
End Sub
End Class
Sub Main()

" & eno)


" & ename)
" & esal)

Dim e1 As New Emp(111, "aaa", 10000)


Dim e2 As New Emp(222, "bbb", 20000)
Dim e3 As New Emp(333, "ccc", 30000)
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Module

5)
Module Module1
Class Emp
Private eno As Integer
Private ename As String
Private esal As Single
Public Sub New()
eno = 111
ename = "aaa"
esal = 10000
End Sub
Public Sub New(ByVal no As Integer)
eno = no
ename = "bbb"
esal = 20000
End Sub
Public Sub New(ByVal no As Integer, ByVal name As String)
eno = no
ename = name
esal = 30000
End Sub
Sub New(ByVal eno As Integer, ByVal ename As String, ByVal esal As Singl
e)
[Link] = eno

[Link] = ename
[Link] = esal
End Sub
Public Sub empData()
[Link]("Emp Number
[Link]("Emp Name
[Link]("Emp Salary
End Sub
End Class
Sub Main()
Dim
Dim
Dim
Dim

e1
e2
e3
e4

As
As
As
As

New
New
New
New

" & eno)


" & ename)
" & esal)

Emp()
Emp(222)
Emp(333, "ccc")
Emp(444, "ddd", 4000)

[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Module

Destructor
===============
Module Module1
Class Demo
Private n As Integer
Sub New()
n = 1000
[Link]("Value of N is " & n)
End Sub
Protected Overrides Sub finalize()
n = 0
[Link]("Value of N is " & n)
End Sub
End Class
Sub Main()
Dim d As New Demo
[Link]()
End Sub
End Module

Shared Data members (Static Data Memsbers)


==================================
-> The Shared Data Members can access without an object,thought the class Name

-> The Shard Data members con't be allocate memory to the object, but it alloca
te only one copy of memory to all the object, that memory we can share all the o
bjects.

1)
Module Module1
Class Emp
Public Shared eno As Integer
Public Shared ename As String
Public Shared esal As Single
End Class
Sub Main()
[Link] = 111
[Link] = "Nikil"
[Link] = 10000
[Link]("Emp Number " & [Link])
[Link]("Emp Name
" & [Link])
[Link]("Emp Salary " & [Link])

[Link]()
End Sub
End Module

2)
Module Module1
Class Test
Private Shared n As Integer
Public Sub getData()
[Link]("Enter N Vaue ")
n = [Link]
End Sub
Public Sub dispData()
[Link]("VALUE OF N IS " & n)
End Sub
End Class
Sub Main()
Dim t1 As New Test
Dim t2 As New Test
Dim t3 As New Test
[Link]()
[Link]()
[Link]()

[Link]()
[Link]()
[Link]()

[Link]()
End Sub
End Module

3)
Module Module1
Class Emp
Private
Private
Private
Private

eno As Integer
ename As String
esal As Single
Shared rno As Integer

Public Sub getEmp()


rno = rno + 1
[Link]("Record Number " & rno)
[Link]("Enter Emp Number ")
eno = [Link]
[Link]("Enter Emp Name
")
ename = [Link]
[Link]("Enter Emp Salary ")
esal = [Link]
End Sub
Public Sub dispEmp()
[Link]("EMP NUMBER " & eno)
[Link]("EMP NAME
" & ename)
[Link]("EMP SALARY " & esal)
End Sub
End Class
Sub Main()
Dim e1 As New Emp
Dim e2 As New Emp
Dim e3 As New Emp
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()

[Link]()
End Sub
End Module
Static Member Functions
=====================
-> The Shared Method can access only those are Shared Fileds.
-> The Shared Method can access without an object through the class Name
-> if we wat to access the non shared fields in shared method the object refera
nce
shoud be needed.
1)
Module Module1
Class Demo
Private Shared x As Integer
Public Shared Sub demoData()
[Link]("Enter Value of X ")
x = [Link]
[Link]("Value of x is " & x)
End Sub
End Class
Sub Main()
Dim d As New Demo
[Link]()
[Link]()
End Sub
End Module

2)
Module Module1
Class Demo
Private x As Integer
Public Shared Sub demoData()
Dim d As New Demo
[Link]("Enter Value of X ")
d.x = [Link]
[Link]("Value of x is " & d.x)
End Sub
End Class
Sub Main()
[Link]()
[Link]()
End Sub

End Module

3)
Module Module1
Class Demo
Private x As Integer
Public Shared Function getData() As Demo
Dim d As New Demo
[Link]("Enter Value of X ")
d.x = [Link]
Return d
End Function
Public Shared Sub dispData(ByVal d As Demo)
[Link]("Value of x is " & d.x)
End Sub
End Class
Sub Main()
Dim d As New Demo
d = [Link]()
[Link](d)
[Link]()
End Sub
End Module
Inheritance
============
1)
Module Module1
Class Stud
Private sno As Integer
Private sname As String
Public Sub getStud()
[Link]("Enter Student Number
sno = [Link]
[Link]("Enter Sudent Name
sname = [Link]
End Sub
Public Sub dispStud()
[Link]("STUDENT NUMBER
[Link]("STUDENT NAME
End Sub
End Class
Class Marks
Inherits Stud

")
")

" & sno)


" & sname)

Private m1 As Integer
Private m2 As Integer
Public Sub getMarks()
getStud()
[Link]("Enter Marks in Paper I
m1 = [Link]
[Link]("Enter Marks in Paper II
m2 = [Link]
End Sub
Public Sub dispMarks()
dispStud()
[Link]("MARKS IN PAPER I "
[Link]("MARKS IN PAPER II "
End Sub
End Class

")
")

& m1)
& m2)

Sub Main()
Dim M As New Marks
[Link]()
[Link]()
[Link]()
End Sub
End Module

2)
Module Module1
Class Stud
Private sno As Integer
Private sname As String
Public Sub getStud()
[Link]("Enter Student Number
sno = [Link]
[Link]("Enter Sudent Name
sname = [Link]
End Sub
Public Sub dispStud()
[Link]("STUDENT NUMBER
[Link]("STUDENT NAME
End Sub
End Class

")
")

" & sno)


" & sname)

Class Marks
Inherits Stud
Protected m1 As Integer
Protected m2 As Integer
Public Sub getMarks()
getStud()
[Link]("Enter Marks in Paper I ")
m1 = [Link]
[Link]("Enter Marks in Paper II ")
m2 = [Link]
End Sub
Public Sub dispMarks()

dispStud()
[Link]("MARKS IN PAPER I " & m1)
[Link]("MARKS IN PAPER II " & m2)
End Sub
End Class
Class Result
Inherits Marks
Private tot As Integer
Private avg As Single
Public Sub getRes()
getMarks()
tot = m1 + m2
avg = tot / 2
End Sub
Public Sub dispRes()
dispMarks()
[Link]("TOTAL MARKS " & tot)
[Link]("AVERAGE MARKS " & avg)
End Sub
End Class
Sub Main()
Dim r As New Result
[Link]()
[Link]()
[Link]()
End Sub
End Module
3)
Basec class
Stud
Der1
Ec

Der2
Cs

Der3
It

Module Module1
Class Stud
Private sno As Integer
Private sname As String
Public Sub getStud()
[Link]("Enter Student Number
sno = [Link]
[Link]("Enter Sudent Name
sname = [Link]
End Sub
Public Sub dispStud()
[Link]("STUDENT NUMBER
[Link]("STUDENT NAME
End Sub
End Class

")
")

" & sno)


" & sname)

Class Ec
Inherits Stud
Private ec1, ec2 As Integer
Public Sub getEc()
getStud()
[Link]("Enter Marks in Ec Paper I ")
ec1 = [Link]
[Link]("Enter Marks in Ec Paper II ")
ec2 = [Link]
End Sub
Public Sub dispEc()
dispStud()
[Link]("MARKS IN EC PAPER I " & ec1)
[Link]("MARKS IN EC PAPER II " & ec2)
End Sub
End Class
Class Cs
Inherits Stud
Private cs1, cs2 As Integer
Public Sub getCs()
getStud()
[Link]("Enter Marks in Cs Paper I ")
cs1 = [Link]
[Link]("Enter Marks in Cs Paper II ")
cs2 = [Link]
End Sub
Public Sub dispCs()
dispStud()
[Link]("MARKS IN CS PAPER I " & cs1)
[Link]("MARKS IN CS PAPER II " & cs2)
End Sub
End Class
Class It
Inherits Stud
Private it1, it2 As Integer
Public Sub getIt()
getStud()
[Link]("Enter Marks in It Paper I ")
it1 = [Link]
[Link]("Enter Marks in It Paper II ")
it2 = [Link]
End Sub
Public Sub dispIt()
dispStud()
[Link]("MARKS IN IT PAPER I " & it1)
[Link]("MARKS IN IT PAPER II " & it2)
End Sub
End Class
Sub Main()
Dim ch As Integer
Do
[Link]()
[Link]("[1]. EC ")

[Link]("[2]. CS ")
[Link]("[3]. IT ")
[Link]("[4]. EXIT ")
[Link]("Enter Your Choice..... ")
ch = [Link]
Select Case ch
Case 1
Dim e As New Ec
[Link]()
[Link]()
Case 2
Dim c As New Cs
[Link]()
[Link]()
Case 3
Dim i As New It
[Link]()
[Link]()
End Select
[Link]()
Loop While ch <> 4

End Sub
End Module

Constructors Fireing in Inheritance


============================
Module Module1
Class A
Sub New()
[Link]("This is Class A constructor ")
End Sub
End Class
Class B
Inherits A
Sub New()
[Link]("This is class B Constructor ")
End Sub
End Class
Class C
Inherits B
Sub New()
[Link]("This is Class C Constructor ")
End Sub
End Class
Sub Main()
Dim c As New C

[Link]()
End Sub
End Module

Paramater Passing to the constructor in Inheritance


=========================================
Module Module1
Class A
Dim x As Integer
Sub New(ByVal p As Integer)
x = p
[Link]("This
End Sub
End Class
Class B
Inherits A
Dim y As Integer
Sub New(ByVal p As Integer,
[Link](p)
y = q
[Link]("This
End Sub
End Class
Class C
Inherits B
Dim z As Integer
Sub New(ByVal p As Integer,
[Link](p, q)
z = r
[Link]("This
End Sub
End Class
Sub Main()
Dim c As New C(10, 20, 30)
[Link]()
End Sub
End Module

Destructrs Firing in Inheritance


=============================
Module Module1
Class A
Dim x As Integer
Sub New(ByVal p As Integer)

is Class A constructor " & x)

ByVal q As Integer)
is class B Constructor " & y)

ByVal q As Integer, ByVal r As Integer)


is Class C Constructor " & z)

x = p
[Link]("This is Class A
End Sub
Protected Overrides Sub finalize()
[Link]("This is Class A
End Sub
End Class
Class B
Inherits A
Dim y As Integer
Sub New(ByVal p As Integer, ByVal q As
[Link](p)
y = q
[Link]("This is class B
End Sub
Protected Overrides Sub finalize()
[Link]()
[Link]("This is Class B
End Sub

constructor " & x)


Detructor ")

Integer)
Constructor " & y)

Detructor ")

End Class
Class C
Inherits B
Dim z As Integer
Sub New(ByVal p As Integer, ByVal q As Integer, ByVal r As Integer)
[Link](p, q)
z = r
[Link]("This is Class C Constructor " & z)
End Sub
Protected Overrides Sub finalize()
[Link]()
[Link]("This is Class C Detructor ")
End Sub
End Class
Sub Main()
Dim c As New C(10, 20, 30)
[Link]()
End Sub
End Module
Creation of the Namespace
=======================
1)
Imports [Link]
Imports [Link]
Namespace Collage
Class Stud
Public Sub studData()
[Link]("Student Class Method ")
End Sub
End Class

Class Library
Public Sub libData()
[Link]("This is Library Class Method ")
End Sub
End Class
Namespace Staff
Class Teaching
Public Sub teachData()
[Link]("This is Teaching Class Method ")
End Sub
End Class
Class Nonteaching
Public Sub nonteachData()
[Link]("This is Non teaching Class Method")
End Sub
End Class
End Namespace
End Namespace
Module Module1
Sub Main()
'Dim
'Dim
'Dim
'Dim
Dim
Dim
Dim
Dim

s
l
t
n
s
l
t
n

As
As
As
As
As
As
As
As

New
New
New
New
New
New
New
New

[Link]
[Link]
[Link]
[Link]
Stud
Library
Teaching
Nonteaching

[Link]()
[Link]()
[Link]()
[Link]()

[Link]()
End Sub
End Module
creation of the Propertys
====================

Module Module1
Class Emp
Public eno As Integer
Public ename As String
Private eage As Integer

Private esal As Single


Public Property empAge()
Get
Return eage
End Get
Set(ByVal value)
eage = value
End Set
End Property
Public Property empSal()
Get
Return esal
End Get
Set(ByVal value)
esal = value
End Set
End Property
Public Sub empData()
[Link]("EMP NUMBER
[Link]("EMP NAME
[Link]("EMP SALARY
End Sub
End Class
Sub Main()
Dim e As New Emp
[Link] = 111
[Link] = "Nikil"
[Link] = 20
[Link] = 20000
[Link]()

[Link]()
End Sub
End Module

Poly
====
Function Overloading
-------------------------Module Module1
Public Sub disp(ByVal a As Integer)
[Link](a)
End Sub
Public Sub disp(ByVal a As String)
[Link](a)
End Sub
Public Sub disp(ByVal a As Single)
[Link](a)
End Sub

" & eno)


" & ename)
" & esal)

Sub Main()
disp(10)
disp("A")
disp(50.5F)
disp("BDPS")
[Link]()
End Sub
End Module

2)
Module Module1
Class One
Public Sub disp()
[Link]("This is Class One Disp Method ")
End Sub
End Class
Class Two
Inherits One
Public Sub disp()
[Link]()
[Link]("This is Class Two Disp Method ")
End Sub
End Class
Sub Main()
Dim t As New Two
[Link]()

[Link]()
End Sub
End Module
3)
Module Module1
Class Ho
Public Overridable Sub Income()
[Link]("This is Ho Class Income Method ")
End Sub
End Class
Class Branch1
Inherits Ho
Public Overrides Sub Income()
[Link]("This is Branch1 Class Income Method ")
End Sub
End Class
Class Branch2
Inherits Ho

Public Overrides Sub Income()


[Link]("This is Branch2 Class Income Method ")
End Sub
End Class
Class Branch3
Inherits Ho
Public Overrides Sub Income()
[Link]("This is Branch3 Class Income Method ")
End Sub
End Class
Sub Main()
'Dim
'Dim
'Dim
'Dim

h As New Ho
b1 As New Branch1
b2 As New Branch2
b3 As New Branch3

'[Link]()
'[Link]()
'[Link]()
'[Link]()
Dim
Dim
Dim
Dim
Dim

h As Ho
b1 As New Branch1
b2 As New Branch2
b3 As New Branch3
x As New Ho

[Link]()
h = b1
[Link]()
h = b2
[Link]()
h = b3
[Link]()

[Link]()
End Sub
End Module

mustInherit
==========
Module Module1
MustInherit Class One
Public Sub oneData()
[Link]("This is Class One Income Method ")
End Sub

End Class
Class Two
Inherits One
Public Sub twoData()
[Link]("This is Class Two Income Method ")
End Sub
End Class
Sub Main()
Dim t As New Two
[Link]()
[Link]()

[Link]()
End Sub
End Module

Notinheritable
==============
Module Module1
Class One
Public Sub oneData()
[Link]("This is Class One Income Method ")
End Sub
End Class
NotInheritable Class Two
Inherits One
Public Sub twoData()
[Link]("This is Class Two Income Method ")
End Sub
End Class
Class Three
Inherits Two
Public Sub threeData()
[Link]("This is Class Three Income Method")
End Sub
End Class
Sub Main()
Dim t As New Three
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Module
Error Haindling
=============

On Error ResumeNext
==================
Module Module1
Sub Main()
On Error Resume Next
Dim a, b, c As Integer
c = 300
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a \ b
[Link]("Result

: " & c)

[Link]("Thank YOu")
[Link]()
End Sub
End Module

2)
Module Module1
Sub Main()
On Error GoTo One
Dim a, b, c As Integer
c = 300
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a \ b
[Link]("Result

: " & c)

[Link]("Thank YOu")
[Link]()
Exit Sub
one:
[Link](" Error " & [Link])

[Link]()
End Sub

End Module

Exception Handling
=================
Try
<Body of the Program>
Catch <Class Name <Object>
<Exception Statements>
Catch <Class Name <Object>
<Exception Statements>
. . . ..
[ Finally
<Final Statmetns> ]
End Try

1)
Module Module1
Sub Main()
Try
Dim a, b, c As Integer
c = 300
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a \ b
[Link]("Result

: " & c)

Catch ex As DivideByZeroException
[Link]([Link])
End Try

[Link]()
End Sub
End Module

2)

Module Module1
Sub Main()
Try
Dim a, b, c As Integer
c = 300
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a \ b
[Link]("Result

: " & c)

Catch ex As InvalidCastException
[Link]([Link])
End Try

[Link]()
End Sub
End Module

3)
Module Module1
Sub Main()
Try
Dim a, b, c As Integer
c = 300
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a \ b
[Link]("Result

: " & c)

Catch ex As OverflowException
[Link]([Link])

End Try

[Link]()
End Sub

End Module

4)
Module Module1
Sub Main()
Try
Dim a, b, c As Integer
c = 300
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a \ b
[Link]("Result

: " & c)

Catch ex As OverflowException
[Link]([Link])
Catch ex As DivideByZeroException
[Link]([Link])
Catch ex As InvalidCastException
[Link]([Link])
End Try

[Link]()
End Sub
End Module

5)
Module Module1
Sub Main()
Try
Dim a, b, c As Integer
c = 300
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a \ b
[Link]("Result
Catch ex As Exception

: " & c)

[Link]([Link])
End Try

[Link]()
End Sub
End Module
6)
Module Module1
Sub Main()
Try
Dim a, b, c As Integer
c = 300
[Link]("Enter Value of A ")
a = [Link]
[Link]("Enter Value of B ")
b = [Link]
c = a \ b
[Link]("Result : " & c)
Catch ex As OverflowException
[Link]([Link])
Catch ex As DivideByZeroException
[Link]([Link])
Catch ex As InvalidCastException
[Link]([Link])
Catch ex As Exception
[Link]([Link])
Finally
[Link]("Thank You")
End Try
[Link]()
End Sub
End Module

User Defined Exception


=======================
Module Module1
Class MyException
Inherits Exception
Sub New(ByVal msg As String)
[Link](msg)
End Sub
End Class
Sub Main()

Try
Dim n As Integer
[Link]("Enter N Value ")
n = [Link]
If n > 10000 Then
Throw New MyException("Value must be <=10000")
End If
[Link]("VALUE OF N IS " & n)
Catch ex As Exception
[Link]([Link])
End Try
[Link]()
End Sub
End Module

Multy threading
=============
1)
Module Module1
Public Sub fun1()
Dim i As Integer
For i = 1 To 250
[Link]("A")
Next
End Sub
Public Sub fun2()
Dim j As Integer
For j = 1 To 250
[Link]("B")
Next
End Sub
Public Sub fun3()
Dim k As Integer
For k = 1 To 250
[Link]("C")
Next
End Sub
Sub Main()
Dim t1 As New [Link](AddressOf fun1)
Dim t2 As New [Link](AddressOf fun2)
Dim t3 As New [Link](AddressOf fun3)
[Link]()

[Link]()
[Link]()
[Link]()
End Sub
End Module
2) sleep
Imports [Link]
Module Module1
Dim t1 As Thread
Dim t2 As Thread
Dim t3 As Thread
Public Sub fun1()
Dim i As Integer
[Link](1000)
For i = 1 To 250
[Link]("A")
Next
End Sub
Public Sub fun2()
Dim j As Integer
[Link](500)
For j = 1 To 250
[Link]("B")
Next
End Sub
Public Sub fun3()
Dim k As Integer
For k = 1 To 250
[Link]("C")
Next
End Sub
Sub Main()
t1 = New Thread(AddressOf fun1)
t2 = New Thread(AddressOf fun2)
t3 = New Thread(AddressOf fun3)
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Module

3) Join

Imports [Link]
Module Module1
Dim t1 As Thread
Dim t2 As Thread
Dim t3 As Thread
Public Sub fun1()
Dim i As Integer
For i = 1 To 250
[Link]("A")
Next
End Sub
Public Sub fun2()
Dim j As Integer
[Link]()
For j = 1 To 250
[Link]("B")
Next
End Sub
Public Sub fun3()
Dim k As Integer
For k = 1 To 250
[Link]("C")
Next
End Sub
Sub Main()
t1 = New Thread(AddressOf fun1)
t2 = New Thread(AddressOf fun2)
t3 = New Thread(AddressOf fun3)
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Module

4)
Imports [Link]
Module Module1
Dim t1 As Thread
Dim t2 As Thread
Dim t3 As Thread
Public Sub fun1()
Dim i As Integer
For i = 1 To 250

[Link]("A")
Next
End Sub
Public Sub fun2()
Dim j As Integer
For j = 1 To 250
[Link]("B")
Next
End Sub
Public Sub fun3()
Dim k As Integer
[Link]()
For k = 1 To 250
[Link]("C")
Next
End Sub
Sub Main()
t1 = New Thread(AddressOf fun1)
t2 = New Thread(AddressOf fun2)
t3 = New Thread(AddressOf fun3)
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Module

5)
Imports [Link]
Module Module1
Dim t1 As Thread
Dim t2 As Thread
Dim t3 As Thread
Public Sub fun1()
Dim i As Integer
For i = 1 To 250
[Link]("A")
Next
End Sub
Public Sub fun2()
Dim j As Integer
For j = 1 To 250
[Link]("B")
Next
End Sub
Public Sub fun3()
Dim k As Integer

[Link]()
For k = 1 To 250
[Link]("C")
Next
[Link]()
End Sub
Sub Main()
t1 = New Thread(AddressOf fun1)
t2 = New Thread(AddressOf fun2)
t3 = New Thread(AddressOf fun3)
[Link]()
[Link]()
[Link]()
[Link]()
End Sub
End Module

You might also like