Advertisement
Guest User

Jaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaack

a guest
Jan 30th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. Option Explicit
  2. '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
  3. Private Sub cmdCalculate_Click()
  4. 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
  5.  
  6. Call read_from_file(Customer_ID(), Ticket_ID(), Number_of_Tickets(), method_of_purchase())
  7. Call popular_method_of_purchase(method_of_purchase())
  8. Call get_ticket_price(Ticket_ID(), Number_of_Tickets())
  9. Call friday_sales(Customer_ID(), Ticket_ID(), Number_of_Tickets(), method_of_purchase())
  10. End Sub
  11. 'This procedure will open a file and attempt to read records in the file.
  12. Private Sub read_from_file(ByRef Customer_ID() As String, Ticket_ID() As String, Number_of_Tickets() As Integer, method_of_purchase() As String)
  13. Dim Index As Integer
  14. Open "H:\Higher Computing\SDD\Choral Shield Assignment\Part 1\Assignment Files\coursework 4 random file 2.csv" For Input As #1
  15. For Index = 1 To 500
  16. Input #1, Customer_ID(Index), Ticket_ID(Index), Number_of_Tickets(Index), method_of_purchase(Index)
  17. Next
  18. Close #1
  19. End Sub
  20. '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.
  21. Private Sub popular_method_of_purchase(ByRef method_of_purchase() As String)
  22. Dim Most_popular As String
  23. Dim School As Integer
  24. Dim Web As Integer
  25. Dim Index As Integer
  26. For Index = 1 To 500
  27. If method_of_purchase(Index) = "S" Then
  28. School = School + 1
  29. Else
  30. Web = Web + 1
  31. End If
  32. Next
  33. If School > Web Then
  34. Most_popular = "School"
  35. Else
  36. Most_popular = "Website"
  37. End If
  38. txtMethod.Text = "The most popular method of purchase is " & Most_popular
  39. End Sub
  40. 'This subprogam will will find out the ticket price from the list of records according to the day.
  41. Private Sub get_ticket_price(ByRef Ticket_ID() As String, Number_of_Tickets() As Integer)
  42. Dim Index As Integer
  43. Dim total As Single
  44. Dim Ticket_price As Integer
  45. total = 0
  46. For Index = 1 To 500
  47. If Ticket_ID(Index) = "F1" Or Ticket_ID(Index) = "F2" Or Ticket_ID(Index) = "F3" Then
  48. Ticket_price = 10
  49. Else
  50. Ticket_price = 5
  51. End If
  52. total = total + (Ticket_price * Number_of_Tickets(Index))
  53. Next
  54. txtTotal.Text = "The total amount raised for charity is " & Format(total, "currency")
  55. End Sub
  56. 'This procedure will write all of Friday night sales to an external file.
  57. Private Sub friday_sales(ByRef Customer_ID() As String, Ticket_ID() As String, Number_of_Tickets() As Integer, method_of_purchase() As String)
  58. Dim Index As Integer
  59. Open "H:\Higher Computing\SDD\Choral Shield Assignment\Part 1\Assignment Files\Fridayfile.csv" For Output As #1
  60. For Index = 1 To 500
  61. If Ticket_ID(Index) = "F1" Or Ticket_ID(Index) = "F2" Or Ticket_ID(Index) = "F3" Then
  62. Write #1, Customer_ID(Index), Ticket_ID(Index), Number_of_Tickets(Index), method_of_purchase(Index)
  63. End If
  64. Next
  65. Close #1
  66. End Sub
  67.  
  68. 'This procedure will end the program
  69. Private Sub cmdEnd_Click()
  70. End
  71. End Sub
  72. 'This will find the date from the Windows Operating System.
  73. Private Sub Form_Load()
  74. lblTitle.Caption = "Essell Academy Choral Shield " & Right(Date, 4)
  75. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement