Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Project: Welcome to the Cage
- 'What is does: Shows the gross amounts of top Nicholas Cage Films
- 'Programmers: Mike Rodenbaugh, Kristina Shealy, Ivan Ledezma, Kirsten Bass
- 'Date: Friday, October 24,
- 'We did not copy this code from the internet. All code as been created by the group
- Public Class frmCage
- 'Declares the arrays strAdj, strUnAdj, and activeString
- Dim strAdj() As String
- Dim strUnAdj() As String
- Dim activeString() As String
- Private Sub frmCage_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- 'Adds text files to form when it loads
- strAdj = IO.File.ReadAllLines("Cage Adjusted.txt")
- strUnAdj = IO.File.ReadAllLines("Cage Unadjusted.txt")
- End Sub
- Private Sub btnExecute_Click(sender As Object, e As EventArgs) Handles btnExecute.Click
- lstBox.Items.Clear() 'Clears list box
- Select Case True
- Case radAdj.Checked 'If radAdj is checked then strAdj becomes the active set of data used
- For Each i In strAdj
- lstBox.Items.Add(DataSelected(i, 1))
- Next
- activeString = strAdj
- btnSwitch.Visible = True
- Case radUnAdj.Checked 'If radUnAdj is checked then radUnAdj becomes the active set of data used
- For Each i In strUnAdj
- lstBox.Items.Add(DataSelected(i, 1))
- Next
- activeString = strUnAdj
- End Select
- 'Setting that are activated after either check box is selected
- radAdj.Visible = False 'radAdj, radUnAdj, and btnExecute are no longer visible
- radUnAdj.Visible = False
- btnExecute.Visible = False
- btnSwitch.Visible = True 'btnSwitch becomes visible
- End Sub
- Private Sub btnQuery_Click(sender As Object, e As EventArgs) Handles btnQuery.Click
- 'filters to only show movies starting with the specified char
- lstBox.Items.Clear()
- If IsNumeric(mtbFirstLetter.Text) = True Then
- MessageBox.Show("Please enter a valid character and try again")
- End If
- Dim movieQuery = From movies In activeString
- Where FirstLetter(movies) = CChar(mtbFirstLetter.Text.ToUpper)
- Select movies
- For Each movie In movieQuery
- lstBox.Items.Add(DataSelected(movie, 1))
- Next
- txtTotalMoney.Text = CStr(AddGrossing(movieQuery))
- End Sub
- Private Sub btnFilter_Click(sender As Object, e As EventArgs) Handles btnSwitch.Click
- 'filters to only show movies starting with the specified char
- lstBox.Items.Clear()
- Dim movieQuery = From movies In activeString
- Where FirstLetter(movies) = CChar(mtbFirstLetter.Text.ToUpper)
- Select movies
- For Each movie In movieQuery
- lstBox.Items.Add(DataSelected(movie, 3))
- Next
- txtTotalMoney.Text = CStr(AddGrossing(movieQuery))
- End Sub
- Function AddGrossing(movieList As System.Collections.Generic.IEnumerable(Of String)) As Integer
- 'switches to looking at gross $
- Dim totalRevenue As Integer = 0
- For Each movie In movieList
- totalRevenue += CInt(DataSelected(movie, 3))
- totalRevenue.ToString("C")
- Next
- Return totalRevenue
- End Function
- Function DataSelected(strArray As String, intElement As Integer) As String
- 'Splits up the string
- Return strArray.Split(CChar(",")).ElementAt(intElement)
- End Function
- Function FirstLetter(movie As String) As Char
- 'pulls the movie using the first letter
- Dim letterUsed As Char
- letterUsed = CChar(DataSelected(movie, 1))
- Return letterUsed
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement