Dim [Variable_Name] As [Datatype] = [Value]
______________
To print the result, we use System.Console.WriteLine(C) which will give the result on the screen
______________
if-then-else
Module Module1
Sub Main()
Dim mikeage, ellenage As Integer
mikeage = 30
ellenage = 27
if mikeage>ellenage
then System.Console.WriteLine(mikeage)
else
System.Console.WriteLine(ellenage)
end if
End Sub
End Module
___________
Switch Statements
. 
___________
For Statements
________
While
_______
Do While
______
Pause in execution:
System.Threading.Thread.Sleep(3000)
______
Class and Object
Module Module1
Class arithmetical
Public Function multiply(ByVal a As Integer, ByVal b As Integer)
Return a * b
End Function
End Class
Sub Main()
Dim objarithmetical As New arithmetical
Console.WriteLine(objarithmetical.multiply(198, 116542))
Console.ReadKey()
End Sub
End Module
_______________________
Stack:
Imports System
Imports System.Collections
Module Module1
Sub Main()
Dim mystr as New Stack()
mystr.Push("S")
mystr.Push("T")
mystr.Push("A")
mystr.Push("C")
mystr.Push("K")
Do While(mystr.count>0)
Console.WriteLine(mystr.Pop())
Loop
End Sub
End Module
The program should return this list.
K
C
A
T
S
_____________________
Array:
Imports System
Imports System.Collections
Module Module1
Sub Main()
Dim Students as New ArrayList()
Students.Add("William")
Students.Add("Tom")
Students.Add("Harry")
For i as Integer=0 to Students.count-1
Console.WriteLine(Students(i))
next
End Sub
End Module
_______
Hashtable:
Imports System
Imports System.Collections
Module Module1
Sub Main()
Dim Employee as New HashTable()
Employee.Add("101","James")
Employee.Add("102","Peter")
Employee.Add("103","Smith")
For each k as string in Employee.keys
Console.WriteLine(k +" " +Employee(k))
next
End Sub
End Module
Output for the above program is:
101 James
102 Peter
103 Smith
No comments:
Post a Comment