Using Structures

As you start to work with real-world data, you’ll frequently encounter situations where you want to deal with a related group of data elements as if they were a single data element. Suppose, for example, that you need to store the following data elements in an array: employee ID, first name, middle initial, and last name.

You already know one way of doing this; you could declare a class named, say, EmpInfo that contained EmpId, FirstName, MI, and LastName properties, and then declare an array of EmpInfo objects. Here’s how this would look in code.

Public Class EmpInfo Public EmpId As String Public FirstName As String Public MI As String Public LastName As String End Class Public Class Form1 Dim empList(100) As EmpInfo End Class ...

Get Faster Smarter Beginning Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.