Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Structure ListLayOut
- Public Name As String
- Public ItemDate As Date
- Public Cost As Decimal
- End Structure
- Sub Main()
- Dim myList As ListLayOut() 'A ListLayOut array. Just like a string array except using our structure as the data type.
- Dim x As Integer = 0
- ReDim myList(x)
- myList(x).Name = "Fred"
- myList(x).ItemDate = System.DateTime.Today
- myList(x).Cost = 42
- x += 1
- ReDim Preserve myList(x)
- myList(x).Name = "Gonzo"
- myList(x).ItemDate = System.DateTime.Today
- myList(x).Cost = 100
- x += 1
- ReDim Preserve myList(x)
- myList(x).Name = "Skippy"
- myList(x).ItemDate = System.DateTime.Today
- myList(x).Cost = 13
- x += 1
- ReDim Preserve myList(x)
- myList(x).Name = "Cirel"
- myList(x).ItemDate = System.DateTime.Today
- myList(x).Cost = 76
- For Each elem In myList
- Console.WriteLine(elem.Name & vbTab & vbTab & elem.ItemDate & " " & elem.Cost)
- Next
- Console.ReadKey()
- Dim itemCost As Decimal
- 'Cost item of the third element of myList being assigned to a variable named itemCost.
- itemCost = myList(3).Cost
- Console.Beep()
- Console.Beep()
- Console.BackgroundColor = ConsoleColor.DarkRed
- Console.ForegroundColor = ConsoleColor.Yellow
- Console.WriteLine("We set the itemCost to the Cost item in the 4th element of myList")
- Console.WriteLine("So itemCost now contains the value " & itemCost.ToString & "!!!")
- Console.Beep()
- Console.Beep()
- Console.ReadKey()
- Console.Beep()
- Console.Beep()
- Console.BackgroundColor = ConsoleColor.DarkCyan
- Console.ForegroundColor = ConsoleColor.DarkBlue
- Console.WriteLine("\m/ (~ ~) \m/")
- Console.ReadKey()
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement