Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- 'Lists
- Dim inData As List(Of Lists.Inputs) = New List(Of Lists.Inputs)()
- #Region "Validates the user input"
- Private Sub ValInput()
- 'Declarations
- Dim tbNum As Boolean = IsNumeric(txtNumber.Text)
- Dim tbName As Boolean = String.IsNullOrEmpty(txtName.Text)
- Dim num As Int16 = txtNumber.Text
- 'Validates user input
- If (tbNum = True) Then
- txtLetter.Text = ConvertGrade(num)
- Else
- txtList.Text = "Invalid input."
- End If
- 'Enter 9999 to display input, or 0 to exit program
- If (num = "9999") Then
- AddInputList()
- txtName.Text = ""
- txtNumber.Text = ""
- txtLetter.Text = ""
- txtName.Focus()
- ElseIf (num = "0") Then
- Me.Close()
- End If
- End Sub
- #End Region
- #Region "Calculates and returns letter grade"
- Private Function ConvertGrade(num As Int16)
- Dim letter As Char
- Select Case num
- Case 90 To 100
- letter = "A"
- Case 80 To 90
- letter = "B"
- Case 70 To 80
- letter = "C"
- Case 60 To 70
- letter = "D"
- Case 0 To 60
- letter = "F"
- Case Else
- letter = "I"
- End Select
- Return letter
- End Function
- #End Region
- #Region "Adds the input to the list"
- Private Sub AddInputList()
- 'Declarations
- Dim name As String
- Dim num As Int16
- Dim letter As Char
- Dim time As Date = DateTime.Now
- name = txtName.Text
- num = txtNumber.Text
- letter = txtLetter.Text
- inData = Lists.InList(name, letter, num, time, inData)
- OutputFromList()
- End Sub
- #End Region
- #Region "Gets the data from the list"
- Private Sub OutputFromList()
- Dim s As String = ""
- 'Moves the most recent entry to the top of the list
- Dim j = inData.Count - 1
- 'Loop that displays name, user, number grade, letter grade, and date/time
- While j <> -1
- s += "Name: " & inData.Item(j).Name & vbNewLine
- s += "System & User: " & My.User.Name & vbNewLine
- s += "Number grade: " & inData.Item(j).Number & vbNewLine
- s += "Letter grade: " & inData.Item(j).Letter & vbNewLine
- s += "Date & Time: " & inData.Item(j).Time & vbNewLine
- j -= 1
- End While
- txtList.Text = s
- End Sub
- #End Region
- #Region "Event Handlers-----------------------------"
- Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
- ValInput()
- End Sub
- Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
- Me.Close()
- End Sub
- #End Region
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement