Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Module VBModule
Sub Main()
'This is a declaration statement
dim Age as integer 'this is a integer whole numbers only
dim Name as string 'this is a string of characters
'dim DoB as date 'this is date time datatype
dim Gender as char ' this is a character
dim Height as decimal 'this is in metres
dim license as boolean ' this is true or false
'Assignment statements
Age = 38
Name = "ChuckNorris"
'DoB = 21/01/1980
Gender = "M"
Height = 2
license = True
Console.WriteLine("Hello, world! Mr " & Name )
Console.Writeline("Your Age is " & Age)
console.writeline("Your DOB is " & date)
Console.Writeline("Your Gender is " & Gender)
Console.write("Your height is: " & Height)
Console.writeline(" Do you have a license: " &license)
End Sub
End Module
Imports System
Public Class Rectangle
Private length As Double
Private width As Double
'Public methods
Public Sub AcceptDetails()
length = 4.5
length = 3.5
End Sub
Public Function GetArea() As Double
GetArea = length *length
End Function
Public Sub Display()
Console.WriteLine("Length: {0}", length)
Console.WriteLine("Width: {0}", length)
Console.WriteLine("Area: {0}", GetArea())
End Sub
Shared Sub Main()
Dim r As New Rectangle()
r.Acceptdetails()
r.Display()
Console.ReadLine()
End Sub
End Class
imports system
Public class rectengle
Private length as double
Private width as double
Public sub Acceptdet()
length=4.5
width=3.5
End sub
Public function getarea() as double
getarea=length*width
End function
Public sub dis()
Console.WriteLine("length:{0}",length)
Console.WriteLine("width:{0}",width)
Console.WriteLine("Area:{0}",getarea())
End sub
shared Sub Main()
dim r as New rectengle()
r.Acceptdet()
r.dis()
console.ReadLine()
End Sub
End Class
Module VBModule
Sub Main()
dim y, phone, local as String
phone = "(01234)567890"
local = phone.Substring(7, 3)
Console.writeline(local)
End Sub
End Module
Module VBModule
Sub Main()
dim A As Integer = 1
dim B As Integer = 1
dim N As Integer = 0
While B < 20
A = A + B
B = A - B
N = N + 1
'Console.WriteLine(A)
Console.WriteLine(B)
End While
'Console.WriteLine(N)
End Sub
End Module
Module VBModule
Sub Main()
dim y, x, phone, local, name as String
y = "Welcome to Computing"
x = UCase(Left(y, 7))
x = Left(Right("Welcome to computing", 12), 2)
y = "Mary had a little lamb"
Console.writeline(Len(y))
y = "Dave had a little lamb. Mary's fleece was white as snow."
Console.writeline(InStr(y,"Mary"))
phone = "(01234)567890"
local = phone.Substring(7, 6)
console.writeline(local)
name = "Craig"
console.writeline("Hello " & name & ". How are you today?")
dim age as decimal
age = CInt(50.27) 'converts the decimal into an integer
console.writeline(age)
End Sub
End Module
Module DataTypes
Sub Main()
Dim b As Byte
Dim n As Integer
Dim si As Single
Dim d As Double
Dim da As Date
Dim c As Char
Dim s As String
Dim bl As Boolean
b = 1
n = 1234567
si = 0.12345678901234566
d = 0.12345678901234566
da = Today
c = "U"c
s = "Me"
If ScriptEngine = "VB" Then
bl = True
Else
bl = False
End If
If bl Then
'the oath taking
Console.Write(c & " and," & s & vbCrLf)
Console.WriteLine("declaring on the day of: {0}", da)
Console.WriteLine("We will learn VB.Net seriously")
Console.WriteLine("Lets see what happens to the floating point variables:")
Console.WriteLine("The Single: {0}, The Double: {1}", si, d)
End If
Console.ReadKey()
End Sub
End Module