Passing Structures to Methods

Structures can be passed to methods as arguments. For example, consider the following method that simulates an order process taking an instance of the previously shown Order structure:

Private Sub ShowOrderInfo(ByVal orderInstance As Order)    Console.WriteLine("Order info:")    Console.WriteLine("ID: {0}, Date received: {1}",                      orderInstance.OrderID,                      orderInstance.OrderDate)    Console.ReadLine()End Sub

You can then invoke the method, passing the desired instance as follows:

Dim firstOrder As New Order(1, Date.Now, Date.Now, 1, 1)ShowOrderInfo(firstOrder)

The preceding code produces an output that looks like this: ...

Get Visual Basic 2015 Unleashed 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.