Results 1 to 25 of 25

Thread: [RESOLVED] Calculate total number of tickets

Threaded View

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] Calculate total number of tickets

    Hi,

    I wrote this code based off a school assignment I had last year which, was in Oracle. However, I can't figure out how to calculate the total number of tickets regardless of whether a ticket is added or subtracted.

    vb Code:
    1. Dim person_table As person_type
    2. Dim staff_table As staff_type
    3. Dim customer_table As customer_type
    4. Dim address_table As address_type
    5. Dim resavation_table As resavation_type
    6. Dim station_table As station_type
    7. Dim ticket_table(2) As ticket_type
    8. Dim ticket() As Variant
    9.  
    10. Private Type person_type
    11. personID As Integer
    12. firstName As String
    13. lastName As String
    14. dob As Date
    15. email As String
    16. phone As String
    17. End Type
    18.  
    19. Private Type staff_type
    20. PTID As person_type
    21. staffID As Long
    22. password As String
    23. End Type
    24.  
    25. Private Type customer_type
    26. PTID As person_type
    27. gender As String
    28. title As String
    29. End Type
    30.  
    31. Private Type address_type
    32. addressID As Integer
    33. street As String
    34. suburb As String
    35. postcode As String
    36. cState As String
    37. addressType As String
    38. personREF As person_type
    39. End Type
    40.  
    41. Private Type resavation_type
    42. resavationID As Integer
    43. customerID As String
    44. resavataionDate  As Date
    45. resavationStatus As String
    46. carriageID As Integer
    47. serviceID As Integer
    48. addressType As String
    49. dateofService As Date
    50. customerREF As customer_type
    51. End Type
    52.  
    53. Private Type station_type
    54. stationID As Integer
    55. stationName As String
    56. ResavationRef As resavation_type
    57. End Type
    58.  
    59. Private Type ticket_type
    60. ticketID As Integer
    61. travellerName As String
    62. resavationID As Integer
    63. stationStart As Integer
    64. stationEnd As Integer
    65. discountID As Integer
    66. carriageID As Integer
    67. seatID As Integer
    68. carriageID1 As Integer
    69. serviceID As Integer
    70. dateofService As Date
    71. stationRef As station_type
    72. End Type
    73.  
    74. Private Sub Form_Load()
    75. Dim tickets As String
    76. person_table.personID = 1
    77. person_table.firstName = "Bob"
    78. person_table.lastName = "Smith"
    79. person_table.dob = 12 - April - 1971
    80. person_table.email = "bobsmith@optus.com"
    81. person_table.phone = "86754345"
    82. MsgBox (person_table.firstName & ", " & person_table.lastName & ", " & person_table.dob & ", " & person_table.email & ", " & person_table.phone)
    83. staff_table.PTID.firstName = "Thomas"
    84. staff_table.PTID.lastName = "Travis"
    85. staff_table.PTID.dob = 22 - Feb - 1982
    86. staff_table.PTID.phone = "22278889"
    87. staff_table.staffID = 78656
    88. staff_table.password = "tfrsewrd"
    89. address_table.addressID = 1
    90. address_table.street = "Wilson St"
    91. address_table.suburb = "Prospect"
    92. address_table.postcode = "5082"
    93. address_table.cState = "SA"
    94. address_table.addressType = "Unit"
    95. address_table.personREF.personID = 1
    96. resavation_table.resavationID = 1
    97. resavation_table.customerID = 1
    98. resavation_table.resavataionDate = 1 - Jan - 2000
    99. resavation_table.resavationStatus = "T"
    100. resavation_table.carriageID = 965
    101. resavation_table.serviceID = 276
    102. resavation_table.dateofService = 27 - July - 2011
    103. resavation_table.customerREF.PTID.personID = 1
    104. station_table.stationID = 1
    105. station_table.stationName = "Adelaide"
    106. station_table.ResavationRef.resavationID = 1
    107.  
    108. ticket = Array("0", "1", "2")
    109. For i = LBound(ticket) To UBound(ticket)
    110. ticket_table(ticket(0)).travellerName = "Bob Smith"
    111. ticket_table(ticket(0)).resavationID = 297
    112. ticket_table(ticket(0)).stationStart = 1
    113. ticket_table(ticket(0)).stationEnd = 3
    114. ticket_table(ticket(0)).discountID = 5
    115. ticket_table(ticket(0)).carriageID = 27
    116. ticket_table(ticket(0)).seatID = 1
    117. ticket_table(ticket(0)).carriageID1 = 7
    118. ticket_table(ticket(0)).dateofService = 5 - Dec - 2000
    119. ticket_table(ticket(0)).stationRef.stationID = 1
    120. ticket_table(0).ticketID = 1
    121. ticket_table(ticket(1)).ticketID = 2
    122. ticket_table(ticket(2)).ticketID = 3
    123. tickets = (ticket_table(i).ticketID)
    124. Next i
    125. MsgBox ("Total number of tickets = " + tickets)
    126. End Sub

    This is the first time I have tried to use types in Visual Basic too.

    Thanks,


    Nightwalker
    Last edited by Nightwalker83; Apr 24th, 2012 at 03:51 AM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width