Module Example4
Sub Main()
Dim sport(5) As String
sport(0) = "Soccer"
sport(1) = "Cricket"
sport(2) = "Hockey"
sport(3) = "Tennis"
sport(4) = "Shooting"
sport(5) = "Swimming"
Console.WriteLine("Name of sport " & sport(2))
For Each i As String In sport
Console.WriteLine(i)
Next
Console.ReadLine()
End Sub
End Module
Showing posts with label VB.Net Examples. Show all posts
Showing posts with label VB.Net Examples. Show all posts
VB.NET Example 3 - For Each Statement
Module Example3
Sub Main()
Dim num As Integer() = {10, 20, 30, 40, 50}
For Each i As Integer In num
Console.WriteLine(i)
Next
Console.ReadLine()
End Sub
End Module
Sub Main()
Dim num As Integer() = {10, 20, 30, 40, 50}
For Each i As Integer In num
Console.WriteLine(i)
Next
Console.ReadLine()
End Sub
End Module
Labels:
For Each Statement,
VB.Net Examples
VB.NET Example 2 - Select Case Statement
Module Example2
Sub Main()
Dim Num As Integer
Console.Write("Enter the Number: ")
Num = Int32.Parse(Console.ReadLine())
Select Case Num
Case 1 To 4
Console.WriteLine("The number is between 1-4")
Case 5 To 7
Console.WriteLine("The number is between 5-7")
Case 8 To 10
Console.WriteLine("The number is between 8-10")
Case Else
Console.WriteLine("The number is above 10")
End Select
Console.ReadLine()
End Sub
End Module
Sub Main()
Dim Num As Integer
Console.Write("Enter the Number: ")
Num = Int32.Parse(Console.ReadLine())
Select Case Num
Case 1 To 4
Console.WriteLine("The number is between 1-4")
Case 5 To 7
Console.WriteLine("The number is between 5-7")
Case 8 To 10
Console.WriteLine("The number is between 8-10")
Case Else
Console.WriteLine("The number is above 10")
End Select
Console.ReadLine()
End Sub
End Module
Labels:
VB.Net Examples
VB.Net Example 1 - Windows Console Application
Module Module1
' A small program in VB.Net Console Application
' Validating if the number entered is less than 10,100 or greater.
Sub Main()
Dim Num As Integer
Console.Write("Enter the Number")
Num = Int32.Parse(Console.ReadLine())
If Num < 10 Then
Console.WriteLine("Number is Less than 10")
ElseIf Num < 100 Then
Console.WriteLine("Number is Less than 100")
Else
Console.WriteLine("An invalid number was entered")
End If
Console.ReadLine()
End Sub
End Module
Int32.Parse: Converts the string representation of a number in a specified style to its 32-bit signed integer equivalent.
' A small program in VB.Net Console Application
' Validating if the number entered is less than 10,100 or greater.
Sub Main()
Dim Num As Integer
Console.Write("Enter the Number")
Num = Int32.Parse(Console.ReadLine())
If Num < 10 Then
Console.WriteLine("Number is Less than 10")
ElseIf Num < 100 Then
Console.WriteLine("Number is Less than 100")
Else
Console.WriteLine("An invalid number was entered")
End If
Console.ReadLine()
End Sub
End Module
Int32.Parse: Converts the string representation of a number in a specified style to its 32-bit signed integer equivalent.
Labels:
VB.Net Examples