I am formally studying VB.NET and the teacher has temporarily left us with a textbook to study.
In a chapter on Arrays an example of actual code is given, as shown at the bottom here.
We use Microsoft Visual Basic 2008 Express edition for our code.
However a simple Copy&Paste of the code below will not work.
To be exact the one Build error is : 'Sub Main' was not found in 'Ex1402.Module1'
where Ex1402 is the name of the Project and Module1 is the module in question
( ie. the default name ).
Any ideas as to the exact problem, please ?
Is it related to the fact that there is no module that actually uses this class
and/or that it is a 'ConsoleApplication' ?
Also does 'Namespace' have anything to do with the problem ?
Thank you in advance.
Option Strict On
Imports System
Namespace ArrayDemo ' a simple class to store in the array
Public Class Employee
Private empID As Integer ' constructor
Public Sub New(ByVal empID As Integer)
Me.empID = empID
End Sub 'New
Public Overrides Function ToString() As String
Return empID.ToString()
End Function 'ToString
End Class 'Employee
Class Tester
Public Sub Run()
Dim intArray() As Integer
Dim empArray() As Employee
intArray = New Integer(5) {}
empArray = New Employee(3) {} ' populate the array
Dim i As Integer
For i = 0 To empArray.Length - 1
empArray(i) = New Employee(i + 5)
Next i
Console.WriteLine("The Integer array...")
For i = 0 To intArray.Length - 1
Console.WriteLine(intArray(i).ToString())
Next i
Console.WriteLine(ControlChars.Lf + "The employee array...")
For i = 0 To empArray.Length - 1
Console.WriteLine(empArray(i).ToString())
Next i
End Sub 'Run
Shared Sub Main()
Dim t As New Tester()
t.Run()
End Sub 'Main
End Class 'Tester
End Namespace 'ArrayDemo