Advertisement
theDrBarnett

Question14 DemoCode

Oct 26th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.97 KB | None | 0 0
  1. Module Module1
  2.     Structure ListLayOut
  3.         Public Name As String
  4.         Public ItemDate As Date
  5.         Public Cost As Decimal
  6.     End Structure
  7.  
  8.  
  9.     Sub Main()
  10.         Dim myList As ListLayOut()     'A ListLayOut array.  Just like a string array except using our structure as the data type.
  11.         Dim x As Integer = 0
  12.  
  13.         ReDim myList(x)
  14.         myList(x).Name = "Fred"
  15.         myList(x).ItemDate = System.DateTime.Today
  16.         myList(x).Cost = 42
  17.  
  18.         x += 1
  19.         ReDim Preserve myList(x)
  20.         myList(x).Name = "Gonzo"
  21.         myList(x).ItemDate = System.DateTime.Today
  22.         myList(x).Cost = 100
  23.  
  24.  
  25.         x += 1
  26.         ReDim Preserve myList(x)
  27.         myList(x).Name = "Skippy"
  28.         myList(x).ItemDate = System.DateTime.Today
  29.         myList(x).Cost = 13
  30.  
  31.         x += 1
  32.         ReDim Preserve myList(x)
  33.         myList(x).Name = "Cirel"
  34.         myList(x).ItemDate = System.DateTime.Today
  35.         myList(x).Cost = 76
  36.  
  37.         For Each elem In myList
  38.             Console.WriteLine(elem.Name & vbTab & vbTab & elem.ItemDate & " " & elem.Cost)
  39.         Next
  40.  
  41.         Console.ReadKey()
  42.  
  43.         Dim itemCost As Decimal
  44.  
  45.         'Cost item of the third element of myList being assigned to a variable named itemCost.
  46.         itemCost = myList(3).Cost
  47.  
  48.         Console.Beep()
  49.         Console.Beep()
  50.         Console.BackgroundColor = ConsoleColor.DarkRed
  51.         Console.ForegroundColor = ConsoleColor.Yellow
  52.  
  53.         Console.WriteLine("We set the itemCost to the Cost item in the 4th element of myList")
  54.         Console.WriteLine("So itemCost now contains the value " & itemCost.ToString & "!!!")
  55.  
  56.         Console.Beep()
  57.         Console.Beep()
  58.         Console.ReadKey()
  59.  
  60.         Console.Beep()
  61.         Console.Beep()
  62.         Console.BackgroundColor = ConsoleColor.DarkCyan
  63.         Console.ForegroundColor = ConsoleColor.DarkBlue
  64.         Console.WriteLine("\m/ (~ ~) \m/")
  65.         Console.ReadKey()
  66.  
  67.     End Sub
  68.  
  69. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement