Results 1 to 25 of 25

Thread: [RESOLVED] Calculate total number of tickets

Threaded View

  1. #9
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Calculate total number of tickets

    Night

    I'm jumping in for the ride. Like you, I have not worked
    with Types before either.

    Let me focus on 2 segments of your code .. which I
    excerpted from Colin's post.

    Declarations
    Code:
    Dim station_table As station_type
    Dim ticket_table(2) As ticket_type
    Dim ticket() As Variant
    '
    Private Type station_type
        stationID As Integer
        stationName As String
        ResavationRef As resavation_type
    End Type
    Sub ... from Colin
    Code:
    Private Sub Form_Load()
        With station_table
            .stationID = 1
            .stationName = "Adelaide"
            .ResavationRef.resavationID = 1
        End With
        ReDim Preserve Tickets(3)
        With Tickets(1)
             .ticketID = 1
             .travellerName = "Bob Smith"
             .resavationID = 297
             .stationStart = 1
             .stationEnd = 3
             .discountID = 5
             .carriageID = 27
             ' ..... other data here
         End With       
         With Tickets(2)
             .ticketID = 2
             ' ..... other data here
         End With        
         With Tickets(3)
             .ticketID = 3
             ' ..... other data here
         End With      
         MsgBox ("Total number of tickets = " & UBound(Tickets))
    End Sub
    A few observations .. mainly questions as I'm new at this too
    1. why is ticket_table(2) dim'd as an array? .. the other Types aren't.
    2. why isn't there a Private Type ticket_table declaration?
    3. where do Tickets(1), ..(2), ..(3) come from? .. not declared anywhere
    4. to deal with your "unsold ticket 2" issue, you might need a loop


    EDIT:

    I thought I'd give your OP another look-see ...

    Sub ... excerpted from your OP
    Code:
    Private Sub Form_Load()
        Dim tickets As String
        ticket = Array("0", "1", "2")
        For i = LBound(ticket) To UBound(ticket)
            ticket_table(ticket(0)).travellerName = "Bob Smith"
            ticket_table(ticket(0)).resavationID = 297
            ticket_table(ticket(0)).stationStart = 1
            ticket_table(ticket(0)).stationEnd = 3
            ticket_table(ticket(0)).discountID = 5
            ticket_table(ticket(0)).carriageID = 27
            ticket_table(ticket(0)).seatID = 1
            ticket_table(ticket(0)).carriageID1 = 7
            ticket_table(ticket(0)).dateofService = 5 - Dec - 2000
            ticket_table(ticket(0)).stationRef.stationID = 1
            ticket_table(0).ticketID = 1
            ticket_table(ticket(1)).ticketID = 2
            ticket_table(ticket(2)).ticketID = 3
            tickets = (ticket_table(i).ticketID)
        Next i
        MsgBox ("Total number of tickets = " + tickets)
    End Sub
    Most of my earlier questions remain.

    Spoo
    Last edited by Spoo; Apr 24th, 2012 at 08:55 PM.

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