Sub Main()
Dim MyInt As Integer = 7
Console.WriteLine("Initialized myInt: {0}", MyInt)
MyInt = 5
Console.WriteLine("After assignment myInt: {0}", MyInt)
End Sub
Module Module1
Sub Main()
Const FreezingPoint As Integer = 32 ' degrees Farenheit
Const BoilingPoint As Integer = 212
System.Console.WriteLine("Freezing point of water: {0}", FreezingPoint)
System.Console.WriteLine("Boiling point of water: {0}", BoilingPoint)
End Sub
End Module
Module Module1
Enum Temperatures
WickedCold = 0
FreezingPoint = 32
LightJacketWeather = 60
SwimmingWeather = 72
BoilingPoint = 212
End Enum 'Temperatures
Sub Main()
System.Console.WriteLine("Freezing point of water: {0}", Temperatures.FreezingPoint)
System.Console.WriteLine("Boiling point of water: {0}", Temperatures.BoilingPoint)
System.Console.WriteLine("Freezing point of water: {0}", CInt(Temperatures.FreezingPoint))
System.Console.WriteLine("Boiling point of water: {0}", CInt(Temperatures.BoilingPoint))
End Sub
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Console.WriteLine("In Main! Calling SomeMethod()...")
SomeMethod()
Console.WriteLine("Back in Main().")
End Sub 'Main
Sub SomeMethod()
Console.WriteLine("Greetings from SomeMethod!")
End Sub 'someMethod
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim valueOne As Integer = 10
Dim valueTwo As Integer = 20
Dim valueThree As Integer = 30
Console.WriteLine("Testing valueOne against valueTwo...")
If valueOne > valueTwo Then
Console.WriteLine("ValueOne: {0} larger than ValueTwo: {1}", valueOne, valueTwo)
End If
Console.WriteLine("Testing valueThree against valueTwo..")
If valueThree > valueTwo Then
Console.WriteLine("ValueThree: {0} larger than ValueTwo: {1}", valueThree, valueTwo)
End If
Console.WriteLine("Testing is valueTwo > 15 (one line)...")
If valueTwo > 15 Then
Console.WriteLine("Yes it is.")
End If
End Sub 'Main
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim valueOne As Integer = 10
Dim valueTwo As Integer = 20
Dim valueThree As Integer = 30
Console.WriteLine("Testing valueOne against valueTwo...")
If valueOne > valueTwo Then
Console.WriteLine("ValueOne: {0} larger than ValueTwo: {1}", valueOne, valueTwo)
Else
Console.WriteLine("Nope, ValueOne: {0} is NOT larger than valueTwo: {1}", valueOne, valueTwo)
End If
End Sub
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim temp As Integer = 32
If temp <= 32 Then
Console.WriteLine("Warning! Ice on road!")
If temp = 32 Then
Console.WriteLine("Temp exactly freezing, beware of water.")
Else
Console.WriteLine("Watch for black ice! Temp:{0}", temp)
End If 'temp = 32
End If 'temp <=32
End Sub 'Main
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim temp As Integer = -32
If temp > 32 Then
Console.WriteLine("Safe driving...")
ElseIf temp = 32 Then
Console.WriteLine("Warning, 32 degrees, watch for ice and water")
ElseIf temp > 0 Then
Console.WriteLine("Watch for ice...")
ElseIf temp = 0 Then
Console.WriteLine("Temperature = 0")
Else
Console.WriteLine("Tmeperatures below zero, Wicked Cold!")
End If
End Sub
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim targetInteger As Integer = 15
Select Case targetInteger
Case 5
Console.WriteLine("5")
Case 10
Console.WriteLine("10")
Case 15
Console.WriteLine("15!")
Case Else
Console.WriteLine("Value not found")
End Select
End Sub
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim target As String = "Milo"
Select Case target
Case "Alpha" To "Lambda"
Console.WriteLine("Alpha to Lamba executed")
Case "Lambda" To "Zeta"
Console.WriteLine("Lambda to Zeta executed")
Case Else
Console.WriteLine("Else executed")
End Select
End Sub
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim counterVariable As Integer = 0
Do While counterVariable < 10
Console.WriteLine("counterVariable: {0}", counterVariable)
counterVariable = counterVariable + 1
Loop ' While counterVariable < 10
End Sub 'Main
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim counterVariable As Integer = 0
Do Until counterVariable = 10
Console.WriteLine("counterVariable: {0}", counterVariable)
counterVariable = counterVariable + 1
Loop ' until countervariable = 10
End Sub
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim counterVariable As Integer = 100
Do
Console.WriteLine("counterVariable: {0}", counterVariable)
counterVariable = counterVariable + 1
Loop While counterVariable < 10
End Sub
End Module
Sub Main()
Dim loopCounter As Integer
For loopCounter = 0 To 9
Console.WriteLine("loopCounter: {0}", loopCounter)
Next
End Sub
Module Module1
Sub Main()
Dim loopCounter As Single
For loopCounter = 0.5 To 9
Console.WriteLine("loopCounter: {0}", loopCounter)
Next
End Sub
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim loopCounter As Single
For loopCounter = 0.5 To 9 Step 0.5
Console.WriteLine("loopCounter: {0}", loopCounter)
Next
End Sub
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim counter As Integer
'count from 1 to 100
For counter = 1 To 100
'display the value
Console.Write("{0} ", counter)
If counter Mod 10 = 0 Then
Console.WriteLine(vbTab & counter)
End If
Next counter
End Sub 'End of Main() method
End Module
Option Strict On
Imports System
Module Module1
Sub Main()
Dim value As Integer = 6
Dim power As Integer = 3
Console.WriteLine("{0} to the {1}rd power is {2}", value, power, value ^ power)
End Sub
End Module
No comments:
Post a Comment