Quantcast
Viewing all articles
Browse latest Browse all 27095

VS 2010 Help with User Defined Functions

Hello, I am new with Visual Basic so I was wondering maybe someone can teach me what I am missing in my studies. I dont need answers, I just need someone to tell me what I missed or mislooked.

Here is the question
Write a program to determine a student’s GPA. The user should enter the grade (A, B, C, D, or F) and the number of credit hours for a course, and then click on the Record This Course button. The user should then repeat this process for all his or her courses. After all the courses have been recorded, the user should click on the Calculate GPA button. A Function procedure should be used to calculate the quality points for a course.

Attachment 98947

Code:

Public Class GPA
    Dim QPoints As Double
    Dim hours As Double


    Private Sub btnRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecord.Click
        QPoints += txtGrade.Text
        txtCredit.Clear()
        txtGrade.Clear()
        txtGrade.Focus()
    End Sub

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        hours += txtCredit.Text
        Dim totalGPA As Double = QPoints * (hours / QPoints)
        txtTotalGPA.Text = CStr(totalGPA)
    End Sub

    Function totalGPA(ByVal A As Double, ByVal B As Double, ByVal C As Double, ByVal D As Double, ByVal F As Double) As Double
        Dim grade As Integer = CDbl(txtGrade.Text)
        Dim cHours As String = CStr(txtCredit.Text)
        Dim gpa = grade * cHours
        Select Case txtGrade.Text
            Case "A"
                Grade += (4 * txtCredit.Text)
            Case "B"
                Grade += (3 * txtCredit.Text)
            Case "C"
                Grade += (2 * txtCredit.Text)
            Case "D"
                Grade += (1 * txtCredit.Text)
            Case "F"
                Grade += (0 * txtCredit.Text)
        End Select
        Return gpa
    End Function

End Class

Attached Images
Image may be NSFW.
Clik here to view.
 

Viewing all articles
Browse latest Browse all 27095

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>