Saturday, May 16, 2009

Code from first example

Module Module1

Sub Main()
Console.WriteLine("Hello World!")
Console.WriteLine("Please enter your name:")
Dim userName As String = Console.ReadLine()
'declaring a variable to hold a String!
Console.WriteLine("Welcome " & userName & " we are glad you are here!")
Console.WriteLine("How many years have you lived?")
Dim ageOfUser As Integer = Console.ReadLine()
Dim userInEightYears As Integer = ageOfUser + 8
Console.WriteLine("In eight years you will be " & userInEightYears & " old")
Console.WriteLine("Someone half your age is " & ageOfUser / 2 & " years old")
Console.WriteLine("Someone twice your age is " & ageOfUser * 2 & " years old")
If ageOfUser > 10 Then
Console.WriteLine("The secret to life is do things you enjoy!")
Else
Console.WriteLine("You already know the secret!")
End If
Console.ReadLine()
'this is conditional logic
End Sub

End Module

No comments: