Sum Function Question

Anyone have any good examples on how this Sum Function works........

I have 3 text boxes Cost1 and Cost 2 and totalCost....I want to select the prices and sum them up and show the total cost in the total cost textbox....im kinda cloudy on how this is done though any suggestions...........thank you for the help




Answer this question

Sum Function Question

  • Steve Conklin

    Moved to Visual Basic from Transact-SQL..

  • Aimee13131

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim berror As Boolean = False

    Dim Total As Decimal = 0

    If IsNumeric(TextBox1.Text) Then

    Total = Total + CType(TextBox1.Text, Decimal)

    ElseIf TextBox1.Text.Trim.Length = 0 Then

    Total = Total + 0

    Else

    berror = True

    End If

    If IsNumeric(TextBox2.Text) Then

    Total = Total + CType(TextBox1.Text, Decimal)

    ElseIf TextBox2.Text.Trim.Length = 0 Then

    Total = Total + 0

    Else

    berror = True

    End If

    If berror = True Then

    TextBox3.Text = "Error"

    Else

    TextBox3.Text = Total.ToString

    End If

    End Sub


  • Sum Function Question