VB program example using function

Find the total, persentage & grade of 5 subject using functions

Sample :



I can't show you complete code Directly so download full code from below .
Download the output to form design.

Dim subj(5) As Double


Private Sub pretext_Change()
    Select Case Val(pretext.Text)
    Case 81 To 100: gradetext.Text = "A"
    Case 61 To 80: gradetext.Text = "B"
    Case 41 To 60: gradetext.Text = "C"
    Case 21 To 40: gradetext.Text = "D"
    Case Is < 21: gradetext.Text = "E"
    End Select
End Sub


Private Sub Text_Change(Index As Integer)
    addmark Me.ActiveControl.Index
End Sub


Private Sub totaltext_Change()
    pretext.Text = Val(totaltext) / 5
End Sub


Private Function addmark(x As Integer)
    totaltext.Text = Val(totaltext.Text) - subj(x)
    subj(x) = Val(Text(x).Text)
    totaltext.Text = Val(totaltext.Text) + subj(x)
End Function


Full Code :
Output(markcalculator.exe)

Full code(markcalculator.doc)

Full project(markcalculator.zip)

*Note Full project require Visual Basic 6.0