can someone help me to find out why my label display is listing the result of the textboxes instead of adding up the values of the text boxes?

here are my codes:

Dim strstudentName As String = (" ")

        Dim dblAssignment1 As Double
        Dim dblAssignment2 As Double
        Dim dblAssignment3 As Double
        Dim dblAssignment4 As Double
        Dim dblMidterm As Double
        Dim dblFinalExam As Double

        strstudentName = (txtStudentName.Text)
        dblAssignment1 = (txtAssignment1.Text)
        dblAssignment2 = (txtAssignment2.Text)
        dblAssignment3 = (txtAssignment3.Text)
        dblAssignment4 = (txtAssignment4.Text)
        dblMidterm = (txtMidterm.Text)
        dblFinalExam = (txtFinalExam.Text)

        lblFinal.Text = "Final Grade is: " + (txtAssignment1.Text + txtAssignment2.Text + txtAssignment3.Text + txtAssignment4.Text + txtMidterm.Text + txtFinalExam.Text)

    End Sub

It's treating the + as a concatenation operator (&) because all the txtAssignment.Text properties are of the String data type. Since you have already put all the txtAssignments into Double variables, try:

lblFinal.Text = "Final Grade is: " + (dblAssignment1 + dblAssignment2 + dblAssignment3 + dblAssignment4 + dblMidterm + dblFinalExam).ToString()

You should do an explicit conversion to Double by

CDbl(txtAssignment1.Text)

but you had better be sure that the string is a valid numeric or you will get an error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.