Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. 'Project: Welcome to the Cage
  2. 'What is does: Shows the gross amounts of top Nicholas Cage Films
  3. 'Programmers: Mike Rodenbaugh, Kristina Shealy, Ivan Ledezma, Kirsten Bass
  4. 'Date: Friday, October 24,
  5. 'We did not copy this code from the internet. All code as been created by the group
  6.  
  7. Public Class frmCage
  8. 'Declares the arrays strAdj, strUnAdj, and activeString
  9. Dim strAdj() As String
  10. Dim strUnAdj() As String
  11. Dim activeString() As String
  12.  
  13.  
  14. Private Sub frmCage_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  15. 'Adds text files to form when it loads
  16. strAdj = IO.File.ReadAllLines("Cage Adjusted.txt")
  17. strUnAdj = IO.File.ReadAllLines("Cage Unadjusted.txt")
  18. End Sub
  19.  
  20. Private Sub btnExecute_Click(sender As Object, e As EventArgs) Handles btnExecute.Click
  21. lstBox.Items.Clear() 'Clears list box
  22. Select Case True
  23. Case radAdj.Checked 'If radAdj is checked then strAdj becomes the active set of data used
  24. For Each i In strAdj
  25. lstBox.Items.Add(DataSelected(i, 1))
  26. Next
  27. activeString = strAdj
  28. btnSwitch.Visible = True
  29. Case radUnAdj.Checked 'If radUnAdj is checked then radUnAdj becomes the active set of data used
  30. For Each i In strUnAdj
  31. lstBox.Items.Add(DataSelected(i, 1))
  32. Next
  33. activeString = strUnAdj
  34. End Select
  35.  
  36. 'Setting that are activated after either check box is selected
  37. radAdj.Visible = False 'radAdj, radUnAdj, and btnExecute are no longer visible
  38. radUnAdj.Visible = False
  39. btnExecute.Visible = False
  40. btnSwitch.Visible = True 'btnSwitch becomes visible
  41.  
  42. End Sub
  43.  
  44. Private Sub btnQuery_Click(sender As Object, e As EventArgs) Handles btnQuery.Click
  45. 'filters to only show movies starting with the specified char
  46. lstBox.Items.Clear()
  47. If IsNumeric(mtbFirstLetter.Text) = True Then
  48. MessageBox.Show("Please enter a valid character and try again")
  49. End If
  50. Dim movieQuery = From movies In activeString
  51. Where FirstLetter(movies) = CChar(mtbFirstLetter.Text.ToUpper)
  52. Select movies
  53.  
  54. For Each movie In movieQuery
  55. lstBox.Items.Add(DataSelected(movie, 1))
  56. Next
  57.  
  58. txtTotalMoney.Text = CStr(AddGrossing(movieQuery))
  59.  
  60. End Sub
  61.  
  62. Private Sub btnFilter_Click(sender As Object, e As EventArgs) Handles btnSwitch.Click
  63. 'filters to only show movies starting with the specified char
  64. lstBox.Items.Clear()
  65.  
  66. Dim movieQuery = From movies In activeString
  67. Where FirstLetter(movies) = CChar(mtbFirstLetter.Text.ToUpper)
  68. Select movies
  69.  
  70. For Each movie In movieQuery
  71. lstBox.Items.Add(DataSelected(movie, 3))
  72. Next
  73.  
  74. txtTotalMoney.Text = CStr(AddGrossing(movieQuery))
  75. End Sub
  76.  
  77.  
  78. Function AddGrossing(movieList As System.Collections.Generic.IEnumerable(Of String)) As Integer
  79. 'switches to looking at gross $
  80. Dim totalRevenue As Integer = 0
  81. For Each movie In movieList
  82. totalRevenue += CInt(DataSelected(movie, 3))
  83. totalRevenue.ToString("C")
  84. Next
  85. Return totalRevenue
  86. End Function
  87.  
  88. Function DataSelected(strArray As String, intElement As Integer) As String
  89. 'Splits up the string
  90. Return strArray.Split(CChar(",")).ElementAt(intElement)
  91. End Function
  92.  
  93. Function FirstLetter(movie As String) As Char
  94. 'pulls the movie using the first letter
  95. Dim letterUsed As Char
  96. letterUsed = CChar(DataSelected(movie, 1))
  97. Return letterUsed
  98. End Function
  99.  
  100. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement