Tutorial - 1 First Program Code: Main .Writeline .Readline
Tutorial - 1 First Program Code: Main .Writeline .Readline
FIRST PROGRAM
CODE
This is the
Module Module1 comment or
Sub Main()
Console.WriteLine("This is my first program")
Console.ReadLine()
Console.ReadLine()
End Sub
End Module
OUTPUT
*END*
TUTORIAL - 2
Data
Types
Logical
Numbers Characters
Operators
Real
Integers Character Strings Boolean
Numbers
ERRORS
1. Syntax Errors (Error in coding syntax) can be checked as follows:
VARIABLES
Sub Main()
Dim MYNUM1 As Integer ' The word "Dim" is used to initiate the variable. Here we
have a variable "MYNUM" whose data type is taken as integer. It means it will deal with
integers
Console.WriteLine(MYNUM1) ' This command will show only the value of variable
"MYNUM1"
Console.ReadLine()
Dim MYNUM2 As Integer = 0 ' Instead of using another line we can assign the value
to variable in the same line
Console.WriteLine(MYNUM2)
Console.ReadLine()
Console.WriteLine(MYNUM2) ' Now system will print the latest value of the
variable which is 4 and not 0
Console.ReadLine()
Dim STRING1 As String = "Hello SAAD" ' String variable is used here
Console.ReadLine()
Console.WriteLine(CHAR1)
Console.ReadLine()
Console.WriteLine(DOUBLE1)
Console.ReadLine()
Console.ReadLine()
Console.WriteLine(MYNUM3)
Console.ReadLine()
Console.ReadLine()
Console.WriteLine(NEWVAR.ToString())
Console.ReadLine()
End Sub
End Module
TUTORIAL – 4
MATH OPERATORS
Module Module1
Sub Main()
Dim NUM1 As Integer = 5
Dim NUM2 As Integer = 5
Dim NUM3 As Integer = Nothing
Console.WriteLine(NUM1 + NUM2) 'Addition
Console.WriteLine(NUM1 - NUM2) 'Subtraction
Console.WriteLine(NUM1 * NUM2) 'Multiplication
Console.WriteLine(NUM1 ^ 2) 'Power/Exponents
Console.WriteLine(NUM1 / NUM2) 'Division
Console.WriteLine(NUM1 Mod NUM2) 'Modulus. That returns the remainder
Console.WriteLine(NUM1 / 4) ' This line will give the caculation 1.25. the
decimals are not related to any variable. This is the calculated result.
NUM3 = NUM1 / 4 'This will not give the output 1.25 as the value will be stored
in NUM3 which is integer and integer value cannot be in decimals
Console.WriteLine(NUM3)
Console.WriteLine(NUM3)
Console.ReadLine()
MYDOUBLE = MYDOUBLE + 10 ' Now new value wil be stored for MYDOUBLE
Console.WriteLine(MYDOUBLE)
MYDOUBLE = 11
Console.WriteLine(MYDOUBLE)
Console.ReadLine()
End Sub
End Module
TUTORIAL – 5
Module Module1
Sub Main()
USERNAME = Console.ReadLine() ' Getting user input. Readline will wait for your
input and USERNAME will store the entered value
Console.WriteLine("Your Name is:" & USERNAME) ' This will print the value of the
variable. "&" is used to concatenate the text and variables
Console.Write("Your Name is:" & USERNAME) ' Instead of WriteLine we used Write.
This will not take the user to next line and print on the same line
Console.WriteLine()
Console.Write("Your Name is:" & USERNAME & " Your Age is:" & AGE & " Your
Salary is:" & SALARY) ' This is another way to write on the same line instead of using
three different line command for "Write"
Console.ReadLine()
End Sub
End Module