Option Strict On
Public Class CArray
Public Shared Sub Main()
Dim dims() As Integer = {10} " Number of elements in array
Dim bnds() As Integer = {1} " Lower bound of array
Dim Scores As Array = Array.CreateInstance(GetType(Integer), dims, bnds)
Console.WriteLine(UBound(Scores))
Console.WriteLine(LBound(Scores))
End Sub
End Class
Module Tester
Sub Main()
Dim Values() As Integer = {100, 200, 300, 400, 500}
Dim MyValues(5) As Integer
Dim Prices() As Double = {25.5, 4.95, 33.4}
Dim I As Integer
For I = 0 To 4
Console.Write(Values(I) & " ")
Next
Console.WriteLine()
Console.WriteLine("Array length: " & Values.Length)
Console.WriteLine("Array lowerbound: " & Values.GetLowerBound(0))
Console.WriteLine("Array upperbound: " & Values.GetUpperBound(0))
End Sub
End Module
Module Tester
Sub Main()
Dim answer, rating As Integer
Dim output As String
Dim responses As Integer()
responses = New Integer() {1, 2, 6, 4, 8, 5, 9, 7, _
8, 10, 1, 6, 3, 8, 6, 10, 3, 8, 2, 7, 6, 5, 7, 6, _
8, 6, 7, 5, 6, 6, 5, 6, 7, 5, 6, 4, 8, 6, 8, 10}
" response frequency array (indices 0 through 10)
Dim frequency As Integer() = New Integer(10) {}
" count frequencies
For answer = 0 To responses.GetUpperBound(0)
frequency(responses(answer)) += 1
Next
Console.WriteLine("Rating " & vbTab & "Frequency ")
For rating = 1 To frequency.GetUpperBound(0)
Console.WriteLine(rating & vbTab & frequency(rating))
Next
End Sub " Main
End Module
public class Test
public Shared Sub Main
Dim aryNames(9) As String
Dim intCounter As Integer
"Show the array boundaries.
Console.WriteLine("LOWER BOUND: " & aryNames.GetLowerBound(0))
Console.WriteLine("UPPER BOUND: " & aryNames.GetUpperBound(0))
Console.WriteLine("LENGTH: " & aryNames.Length)
"Populate the array.
For intCounter = 0 To aryNames.GetUpperBound(0)
aryNames(intCounter) = "Element position = " & intCounter
Next intCounter
"Show the elements of the array.
For intCounter = 0 To aryNames.GetUpperBound(0)
Console.WriteLine("Element position = " & intCounter)
Next intCounter
End Sub
End class
Module Module1
Sub Main()
Dim Scores(2) As Integer
Scores(0) = 45
Scores(1) = 55
Scores(2) = 65
For intLoopIndex As Integer = 0 To UBound(Scores)
Console.WriteLine("Score(" & intLoopIndex & ") = " & Scores(intLoopIndex))
Next intLoopIndex
End Sub
End Module