Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Structure OrderDetails
- Dim CustomerID As Integer
- Dim TicketID As String
- Dim TicketsNo As Integer
- Dim Method As String
- End Structure
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim FileLen As Integer
- Dim OrderDetails(300) As OrderDetails
- ReadFile(FileLen, OrderDetails)
- CountMethod(FileLen, OrderDetails)
- CalculateRaised(FileLen, OrderDetails)
- Output(FileLen, OrderDetails)
- End Sub
- Private Sub ReadFile(ByVal FileLen As Integer, ByVal OrderDetails() As OrderDetails)
- 'File is opened and data from file is processed into OrderDetails
- Dim Counter As Integer
- Dim Filename As String
- Dim CurrentCol() As String
- Filename = "FilePathHere"
- FileOpen(1, Filename, OpenMode.Input)
- Do
- FileLen = FileLen + 1
- CurrentCol = Split(LineInput(1), ",")
- OrderDetails(Counter).CustomerID = CurrentCol(0)
- OrderDetails(Counter).TicketID = CurrentCol(1)
- OrderDetails(Counter).TicketsNo = CurrentCol(2)
- OrderDetails(Counter).Method = CurrentCol(3)
- Loop Until EOF(1)
- FileClose(1)
- End Sub
- Private Sub CountMethod(ByRef FileLen As Integer, ByRef OrderDetails() As OrderDetails)
- Dim OfficeCount As Integer
- Dim WebsiteCount As Integer
- Dim Counter As Integer
- For Counter = 1 To FileLen
- If OrderDetails(Counter).Method = ScrollStateAutoScrolling Then
- OfficeCount = OfficeCount + 1
- Else
- WebsiteCount = WebsiteCount + 1
- End If
- Next
- ListBox1.Items.Add("Essel Academy Choral Shield " & Year(Now))
- If OfficeCount > WebsiteCount Then
- ListBox1.Items.Add("The most popular method of ticket purchase was through the School Office.")
- Else
- ListBox1.Items.Add("The most popular method of ticket purchase was through the website online.")
- End If
- End Sub
- Private Sub CalculateRaised(ByRef FileLen As Integer, ByRef OrderDetails() As OrderDetails)
- Dim TotalRaised As Integer
- For Counter = 1 To FileLen
- If Microsoft.VisualBasic.Left(OrderDetails(Counter).TicketID, 1) = "F" Then
- TotalRaised = TotalRaised + 10 * OrderDetails(Counter).TicketsNo
- Else
- TotalRaised = TotalRaised + 5 * OrderDetails(Counter).TicketsNo
- End If
- Next
- ListBox1.Items.Add("The total amount raised was " & TotalRaised)
- End Sub
- Private Sub Output(ByRef FileLen As Integer, ByRef OrderDetails() As OrderDetails)
- Dim Filename As String
- Filename = "FILEPATHNEW"
- FileOpen(2, Filename, OpenMode.Output)
- For Counter = 1 To FileLen
- If Microsoft.VisualBasic.Left(OrderDetails(Counter).TicketID, 1) = "F" Then
- OrderDetails(Counter).CustomerID()
- End If
- Next
- End Sub
- End Class
- Record Structure OrderDetails[300]
- CustomerID As Integer
- TicketID as String
- TicketsNo as Integer
- Method as String (School Office or Website)
- FileLen as Integer
- 1 ReadFile [OUT: OrderDetails, FileLen]
- 2 CountMethod [IN: OrderDetails, FileLen]
- 3 CalculateRaised [IN: OrderDetails, FileLen]
- 4 WriteFile [In: OrderDetails, FileLen]
- Step 1 -
- Set Filename to "File"
- Open Filename
- REPEAT
- SET FileLen TO FileLen + 1
- RECEIVE OrderDetails.CustomerID
- RECIEVE OrderDetails.TicketID
- RECEIVE OrderDetails.TicketsNo
- UNTIL EndOfFile
- Close Filename
- Step 2 -
- Declare OfficeCount as Integer
- Declare WebsiteCount as Integer
- Declare Counter as Integer
- FOR Counter from 1 TO FileLen
- IF OrderDetails(counter).Method = S THEN
- SET OfficeCount TO OfficeCount + 1
- ELSE
- SET WebsiteCount to WebsiteCount +1
- ENDFOR
- SEND "Essel Academy Choral Shield" & CURRENT YEAR TO DISPLAY
- If OfficeCount > WebsiteCount THEN
- SEND "The most popular method of ticket purchase was through the School Office." TO DISPLAY
- ELSE
- SEND "The most popular method of ticket purchase was through the website online." TO DISPLAY
- Step 3 -
- DECLARE TotalRaised AS Integer
- FOR Counter FROM 1 TO FileLen
- IF left(OrderDetails(Counter).TicketID,1) = "F" THEN
- SET TotalRaised TO TotalRaised + 10 * OrderDetails(Counter).TicketsNo
- ELSE
- SET TotalRaised TO TotalRaised + 5 * OrderDetails(Counter).TicketsNo
- SEND "The total amount raised was " & TotalRaised TO DISPLAY
- Step 4 -
- SET FileName TO "NEW INFO"
- Open FileName
- FOR Counter FROM 1 TO FileLen
- IF Left(OrderDetails(Counter).TicketID = "F" THEN
- SEND OrderDetails(Counter).CustomerID, OrderDetails(Counter).TicketID, OrderDetails.(Counter).TicketsNo, OrderDetails(Counter).Method TO FILEROW
- ENDIF
- Close Filename
- SEND "File exported" TO DISPLAY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement