Thursday, July 7, 2016

STUDENT MARKS CALCULATOR

Student Marks Caculator Source Code
Imports System.Text
Public Class Form1
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Application.Exit()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If validateform() Then
            If (chkfailinpaper() > 0) Then

            Else
                getresult()

            End If

        End If
    End Sub
    Public Function validateform() As Boolean
        Dim flag As Boolean = True
        If txtroll.Text.Length = 0 Then
            MsgBox("Enter Roll Number", MsgBoxStyle.Critical, "Alert Message")
            flag = False
            txtroll.Focus()
        ElseIf txtname.Text.Length = 0
            MsgBox("Enter Student Name", MsgBoxStyle.Critical, "Alert Message")
            flag = False
            txtname.Focus()
        ElseIf txtengmarks.Text.Length = 0
            MsgBox("Enter English Mars", MsgBoxStyle.Critical, "Alert Message")
            flag = False
            txtengmarks.Focus()
        ElseIf txthndmarks.Text.Length = 0
            MsgBox("Enter Hindi Marks", MsgBoxStyle.Critical, "Alert Message")
            flag = False
            txthndmarks.Focus()
        ElseIf txtmatmarks.Text.Length = 0
            MsgBox("Enter Math Marks", MsgBoxStyle.Critical, "Alert Message")
            flag = False
            txtmatmarks.Focus()
        ElseIf txtscimarks.Text.Length = 0
            MsgBox("Enter Science Marks", MsgBoxStyle.Critical, "Alert Message")
            flag = False
            txtscimarks.Focus()
        ElseIf txtsst.Text.Length = 0
            MsgBox("Enter S.St Marks", MsgBoxStyle.Critical, "Alert Message")
            flag = False
            txtsst.Focus()
        ElseIf Not (IsNumeric(txtengmarks.Text))
            MsgBox("Enter Only Numeric Value", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txtengmarks.Clear()
            txtengmarks.Focus()
        ElseIf Not (IsNumeric(txthndmarks.Text))
            MsgBox("Enter Only Numeric Value", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txthndmarks.Clear()
            txthndmarks.Focus()
        ElseIf Not (IsNumeric(txtmatmarks.Text))
            MsgBox("Enter Only Numeric Value", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txtmatmarks.Clear()
            txtmatmarks.Focus()
        ElseIf Not (IsNumeric(txtscimarks.Text))
            MsgBox("Enter Only Numeric Value", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txtscimarks.Clear()
            txtscimarks.Focus()
        ElseIf Not (IsNumeric(txtsst.Text))
            MsgBox("Enter Only Numeric Value", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txtsst.Clear()
            txtsst.Focus()
        ElseIf Integer.Parse(txtengmarks.Text) < 0 Or Integer.Parse(txtengmarks.Text) > 100
            MsgBox("Enter Value Between 0 to 100", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txtengmarks.Clear()
            txtengmarks.Focus()
        ElseIf Integer.Parse(txthndmarks.Text) < 0 Or Integer.Parse(txthndmarks.Text) > 100
            MsgBox("Enter Value Between 0 to 100", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txthndmarks.Clear()
            txthndmarks.Focus()
        ElseIf Integer.Parse(txtmatmarks.Text) < 0 Or Integer.Parse(txtmatmarks.Text) > 100
            MsgBox("Enter Value Between 0 to 100", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txtmatmarks.Clear()
            txtmatmarks.Focus()
        ElseIf Integer.Parse(txtscimarks.Text) < 0 Or Integer.Parse(txtscimarks.Text) > 100
            MsgBox("Enter Value Between 0 to 100", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txtscimarks.Clear()
            txtscimarks.Focus()
        ElseIf Integer.Parse(txtsst.Text) < 0 Or Integer.Parse(txtsst.Text) > 100
            MsgBox("Enter Value Between 0 to 100", MsgBoxStyle.Information, "Alert Message")
            flag = False
            txtsst.Clear()
            txtsst.Focus()
        End If
        Return flag
    End Function
    Public Sub getresult()
        Dim subject(5) As Double
        Dim tmarks, per As Double
        Dim grade As String = String.Empty
        subject(0) = Double.Parse(txtengmarks.Text)
        subject(1) = Double.Parse(txthndmarks.Text)
        subject(2) = Double.Parse(txtmatmarks.Text)
        subject(3) = Double.Parse(txtscimarks.Text)
        subject(4) = Double.Parse(txtsst.Text)

        For counter As Integer = 0 To 4
            tmarks = tmarks + subject(counter)
        Next

        per = tmarks / 5

        If per >= 60 Then
            grade = "A"c
        ElseIf per >= 45
            grade = "B"c
        ElseIf per >= 30
            grade = "C"c
        End If

        txtgrade.Text = grade
        txtper.Text = per.ToString
        totalmarks.Text = tmarks.ToString

    End Sub
    Public Function chkfailinpaper() As Integer
        Dim subject(5) As Double
        Dim strfailpaper As New StringBuilder
        Dim subname() As String = {"English", "Hindi", "Math", "Science", "S.St"}
        Dim countfailpaper As Integer = 0
        subject(0) = Double.Parse(txtengmarks.Text)
        subject(1) = Double.Parse(txthndmarks.Text)
        subject(2) = Double.Parse(txtmatmarks.Text)
        subject(3) = Double.Parse(txtscimarks.Text)
        subject(4) = Double.Parse(txtsst.Text)

        For counter As Integer = 0 To 4
            If subject(counter) < 30 Then
                strfailpaper.Append(subname(counter) & ",")
                countfailpaper = countfailpaper + 1
            End If
        Next
        If (countfailpaper > 0) Then
            clrres()
            MsgBox(strfailpaper.ToString, MsgBoxStyle.Critical, "Fail")
        End If
        Return countfailpaper
    End Function
    Public Sub clrres()
        txtgrade.Clear()
        txtper.Clear()
        totalmarks.Clear()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        clearall()
    End Sub
    Public Sub clearall()
        txtroll.Clear()
        txtname.Clear()
        txtengmarks.Clear()
        txthndmarks.Clear()
        txtmatmarks.Clear()
        txtscimarks.Clear()
        txtsst.Clear()
        txtgrade.Clear()
        txtper.Clear()
        totalmarks.Clear()
        txtroll.Focus()
    End Sub

    Private Sub txtroll_TextChanged(sender As Object, e As EventArgs) Handles txtroll.TextChanged

    End Sub

    Private Sub txtroll_MouseHover(sender As Object, e As EventArgs) Handles txtroll.MouseHover
        ToolTip1.SetToolTip(txtroll, "Enter Roll Number")
    End Sub
    Private Sub txtname_MouseHover(sender As Object, e As EventArgs) Handles txtname.MouseHover
        ToolTip1.SetToolTip(txtname, "Enter Student Name")
    End Sub

    Private Sub dtpdob_MouseHover(sender As Object, e As EventArgs) Handles dtpdob.MouseHover
        ToolTip1.SetToolTip(dtpdob, "Select Date Of Birth")
    End Sub
    Private Sub txtengmarks_MouseHover(sender As Object, e As EventArgs) Handles txtengmarks.MouseHover
        ToolTip1.SetToolTip(txtengmarks, "Enter English Marks")
    End Sub
    Private Sub txthndmarks_MouseHover(sender As Object, e As EventArgs) Handles txthndmarks.MouseHover
        ToolTip1.SetToolTip(txthndmarks, "Enter Hindi Marks")
    End Sub
    Private Sub txtmatmarks_MouseHover(sender As Object, e As EventArgs) Handles txtmatmarks.MouseHover
        ToolTip1.SetToolTip(txtmatmarks, "Enter Math Marks")
    End Sub
    Private Sub txtscimarks_MouseHover(sender As Object, e As EventArgs) Handles txtscimarks.MouseHover
        ToolTip1.SetToolTip(txtscimarks, "Enter Science Marks")
    End Sub
    Private Sub txtsst_MouseHover(sender As Object, e As EventArgs) Handles txtsst.MouseHover
        ToolTip1.SetToolTip(txtsst, "Enter Social Science Marks")
    End Sub
End Class

.................................................................................................................................................................
Click Here To Download Student Marks Calculator Application

0 comments:

Post a Comment