Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- 'I will dim the vairiables I will use later in this program. I will also call the subprograms I will use to create my program and to come to a conclusion
- Private Sub cmdCalculate_Click()
- Dim Customer_ID(1 To 500) As String, Ticket_ID(1 To 500) As String, Number_of_Tickets(1 To 500) As Integer, method_of_purchase(1 To 500) As String, total As Single, Ticket_price As Integer
- Call read_from_file(Customer_ID(), Ticket_ID(), Number_of_Tickets(), method_of_purchase())
- Call popular_method_of_purchase(method_of_purchase())
- Call get_ticket_price(Ticket_ID(), Number_of_Tickets())
- Call friday_sales(Customer_ID(), Ticket_ID(), Number_of_Tickets(), method_of_purchase())
- End Sub
- 'This procedure will open a file and attempt to read records in the file.
- Private Sub read_from_file(ByRef Customer_ID() As String, Ticket_ID() As String, Number_of_Tickets() As Integer, method_of_purchase() As String)
- Dim Index As Integer
- Open "H:\Higher Computing\SDD\Choral Shield Assignment\Part 1\Assignment Files\coursework 4 random file 2.csv" For Input As #1
- For Index = 1 To 500
- Input #1, Customer_ID(Index), Ticket_ID(Index), Number_of_Tickets(Index), method_of_purchase(Index)
- Next
- Close #1
- End Sub
- 'This subprogram will calculate the most popular method of buying tickets. There are two possible ways of purchasing a ticket either from the website or from the school.
- Private Sub popular_method_of_purchase(ByRef method_of_purchase() As String)
- Dim Most_popular As String
- Dim School As Integer
- Dim Web As Integer
- Dim Index As Integer
- For Index = 1 To 500
- If method_of_purchase(Index) = "S" Then
- School = School + 1
- Else
- Web = Web + 1
- End If
- Next
- If School > Web Then
- Most_popular = "School"
- Else
- Most_popular = "Website"
- End If
- txtMethod.Text = "The most popular method of purchase is " & Most_popular
- End Sub
- 'This subprogam will will find out the ticket price from the list of records according to the day.
- Private Sub get_ticket_price(ByRef Ticket_ID() As String, Number_of_Tickets() As Integer)
- Dim Index As Integer
- Dim total As Single
- Dim Ticket_price As Integer
- total = 0
- For Index = 1 To 500
- If Ticket_ID(Index) = "F1" Or Ticket_ID(Index) = "F2" Or Ticket_ID(Index) = "F3" Then
- Ticket_price = 10
- Else
- Ticket_price = 5
- End If
- total = total + (Ticket_price * Number_of_Tickets(Index))
- Next
- txtTotal.Text = "The total amount raised for charity is " & Format(total, "currency")
- End Sub
- 'This procedure will write all of Friday night sales to an external file.
- Private Sub friday_sales(ByRef Customer_ID() As String, Ticket_ID() As String, Number_of_Tickets() As Integer, method_of_purchase() As String)
- Dim Index As Integer
- Open "H:\Higher Computing\SDD\Choral Shield Assignment\Part 1\Assignment Files\Fridayfile.csv" For Output As #1
- For Index = 1 To 500
- If Ticket_ID(Index) = "F1" Or Ticket_ID(Index) = "F2" Or Ticket_ID(Index) = "F3" Then
- Write #1, Customer_ID(Index), Ticket_ID(Index), Number_of_Tickets(Index), method_of_purchase(Index)
- End If
- Next
- Close #1
- End Sub
- 'This procedure will end the program
- Private Sub cmdEnd_Click()
- End
- End Sub
- 'This will find the date from the Windows Operating System.
- Private Sub Form_Load()
- lblTitle.Caption = "Essell Academy Choral Shield " & Right(Date, 4)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement