Visual Basic Student Grade Calculator

100% found this document useful (1 vote)
256 views4 pages
The document contains code for a VB program that calculates student grades and percentages based on marks entered in text boxes. It includes data validation to check for empty text boxes or …
  • Core Code Execution
  • Program Introduction
  • Grade Calculation Logic
  • Output and Error Handling

Mark sheet Program

Code

Option Explicit

Dim marks As String

Dim Perc As Double

Private Sub Command1_Click()

'Comments

'DATA VALIDATION IS VERY IMPORTANT FOR YOUR PROGRAM"

'IF YOU HAVE EMPTY TEXT BOXES AND WANTS TO CALCULATE

'GRADE AND PERCENTAGE THEN PROGRAM INFORM THAT MISTAKE

'SIMILARLY IF YOU ENTER MARKS GREATER THAN 100 IN EACH

'SUBJECT THEN PROGRAM INFORM YOU

' IMPORTANT NOTE: THIS VALIDATION CAN BE MADE BY TWO METHODS

'BY USING OR OPERATORS.

'BY USING IF THEN CONDITIONAL STATEMENT

If [Link] = "" Or [Link] = "" Or [Link] = "" Or [Link] = "" Then


MsgBox "Marks must be Enter"

Exit Sub

End If

If [Link] > 100 Then

MsgBox "Please Enter Correct Marks"

[Link] = ""

[Link]

End If

If [Link] > 100 Then

MsgBox "Please Enter Correct Marks"

[Link] = ""

[Link]

End If

If [Link] > 100 Then

MsgBox "Please Enter Correct Marks"

[Link] = ""

[Link]

End If

If [Link] > 100 Then

MsgBox "Please Enter Correct Marks"

[Link] = ""

[Link]

End If

If IsNumeric([Link]) = False Or IsNumeric([Link]) = False Or IsNumeric([Link]) = False


Or IsNumeric([Link]) = False Then

MsgBox "Please Enter Numric Value"

Exit Sub

End If

marks = Val(Text1) + Val(Text2) + Val(Text3) + Val(Text4)


Perc = marks * 100 / 400

Select Case marks

Case Is >= 320

MsgBox "You have got A+ Grade"

MsgBox Perc

Case 280 To 319

MsgBox "You have got A Grade"

MsgBox Perc

Case 240 To 279

MsgBox "You have got B Grade"

MsgBox Perc

Case 200 To 239

MsgBox "You have got C Grade"

MsgBox Perc

Case 180 To 199

MsgBox "You have got D Grade"

MsgBox Perc

Case Is < 199

MsgBox "Sorry My Dear Please Try Next Year "

MsgBox "No Percentage"

End Select

End Sub

Private Sub Command3_Click()

marks = Val(Text1) + Val(Text2) + Val(Text3) + Val(Text4)

Perc = marks * 100 / 400

If marks >= 320 Then

MsgBox "You have got A+ Grade"


MsgBox Perc

ElseIf marks >= 280 And marks < 320 Then ' Check by using OR Operators

MsgBox "You have got A Grade"

MsgBox Perc

ElseIf marks >= 240 And marks < 279 Then

MsgBox "You have got B Grade"

MsgBox Perc

ElseIf marks >= 200 And marks < 239 Then

MsgBox "You have got C Grade"

ElseIf marks >= 180 And marks < 199 Then

MsgBox "You have got D Grade"

MsgBox Perc

Else

MsgBox "Sorry My Dear Please Try Next Year "

MsgBox "No Percentage"

End If

End Sub

Mark sheet Program 
 
 
Code 
Option Explicit 
Dim marks As String 
Dim Perc As Double 
 
Private Sub Command1_Click()
MsgBox "Marks must be Enter" 
        Exit Sub 
    End If 
    If Text1.Text > 100 Then 
        MsgBox "Please Ente
Perc = marks * 100 / 400 
        Select Case marks 
            Case Is >= 320 
                MsgBox "You have
MsgBox Perc 
        ElseIf marks >= 280 And marks < 320 Then ' Check by using OR Operators 
            MsgBox "

You might also like