Advertisement
stans

Public Class Form1 'Lists Dim inData As List(Of Li

Feb 16th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. Public Class Form1
  2.  
  3. 'Lists
  4. Dim inData As List(Of Lists.Inputs) = New List(Of Lists.Inputs)()
  5.  
  6.  
  7.  
  8. #Region "Validates the user input"
  9.  
  10. Private Sub ValInput()
  11.  
  12. 'Declarations
  13. Dim tbNum As Boolean = IsNumeric(txtNumber.Text)
  14. Dim tbName As Boolean = String.IsNullOrEmpty(txtName.Text)
  15. Dim num As Int16 = txtNumber.Text
  16.  
  17. 'Validates user input
  18.  
  19. If (tbNum = True) Then
  20. txtLetter.Text = ConvertGrade(num)
  21. Else
  22. txtList.Text = "Invalid input."
  23. End If
  24.  
  25.  
  26. 'Enter 9999 to display input, or 0 to exit program
  27. If (num = "9999") Then
  28. AddInputList()
  29.  
  30. txtName.Text = ""
  31. txtNumber.Text = ""
  32. txtLetter.Text = ""
  33. txtName.Focus()
  34.  
  35. ElseIf (num = "0") Then
  36. Me.Close()
  37. End If
  38.  
  39.  
  40. End Sub
  41.  
  42. #End Region
  43.  
  44.  
  45.  
  46. #Region "Calculates and returns letter grade"
  47. Private Function ConvertGrade(num As Int16)
  48.  
  49.  
  50. Dim letter As Char
  51.  
  52. Select Case num
  53.  
  54. Case 90 To 100
  55. letter = "A"
  56. Case 80 To 90
  57. letter = "B"
  58. Case 70 To 80
  59. letter = "C"
  60. Case 60 To 70
  61. letter = "D"
  62. Case 0 To 60
  63. letter = "F"
  64. Case Else
  65. letter = "I"
  66.  
  67. End Select
  68.  
  69. Return letter
  70.  
  71. End Function
  72.  
  73. #End Region
  74.  
  75.  
  76.  
  77. #Region "Adds the input to the list"
  78.  
  79.  
  80. Private Sub AddInputList()
  81.  
  82.  
  83. 'Declarations
  84. Dim name As String
  85. Dim num As Int16
  86. Dim letter As Char
  87. Dim time As Date = DateTime.Now
  88.  
  89.  
  90. name = txtName.Text
  91. num = txtNumber.Text
  92. letter = txtLetter.Text
  93.  
  94.  
  95. inData = Lists.InList(name, letter, num, time, inData)
  96.  
  97.  
  98. OutputFromList()
  99.  
  100.  
  101. End Sub
  102.  
  103. #End Region
  104.  
  105.  
  106.  
  107. #Region "Gets the data from the list"
  108.  
  109.  
  110. Private Sub OutputFromList()
  111.  
  112. Dim s As String = ""
  113.  
  114. 'Moves the most recent entry to the top of the list
  115. Dim j = inData.Count - 1
  116.  
  117. 'Loop that displays name, user, number grade, letter grade, and date/time
  118. While j <> -1
  119.  
  120. s += "Name: " & inData.Item(j).Name & vbNewLine
  121. s += "System & User: " & My.User.Name & vbNewLine
  122. s += "Number grade: " & inData.Item(j).Number & vbNewLine
  123. s += "Letter grade: " & inData.Item(j).Letter & vbNewLine
  124. s += "Date & Time: " & inData.Item(j).Time & vbNewLine
  125.  
  126. j -= 1
  127.  
  128. End While
  129.  
  130. txtList.Text = s
  131.  
  132. End Sub
  133.  
  134. #End Region
  135.  
  136.  
  137.  
  138. #Region "Event Handlers-----------------------------"
  139. Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
  140.  
  141. ValInput()
  142.  
  143. End Sub
  144.  
  145. Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  146.  
  147. Me.Close()
  148.  
  149. End Sub
  150. #End Region
  151.  
  152.  
  153.  
  154. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement