Trying to get the Sum of a Currency held variable
In the function below, I am trying to get the sum of a series of Currency variables (student.p1amt, student.p2amt, etc...)
When I run this, I am getting the concatination of the strings, but not the sum of the numbers. How can I change this to sum the values and store them in the 'amtDue' variable?
Thanks!
Mike
void PaymentsSpace.PaymentsDue()
{
amtDue = "";
for each student in Students [ID != 0]
{
info student.First_Name + " " + student.Last_Name + " " + student.p1rec;
if (student.p1rec.toString() != "Payment 1 Received")
{
amtDue = amtDue + student.p1amt;
}
if (student.p2rec.toString() != "Payment 2 Received")
{
amtDue = amtDue + student.p2amt;
}
if (student.p3rec.toString() != "Payment 3 Received")
{
amtDue = amtDue + student.p3amt;
}
if (student.p4rec.toString() != "Payment 4 Received")
{
amtDue = amtDue + student.p4amt;
}
if (student.p5rec.toString() != "Payment 5 Received")
{
amtDue = amtDue + student.p5amt;
}
if (student.p6rec.toString() != "Payment 6 Received")
{
amtDue = amtDue + student.p6amt;
}
//info "Amount Due: " + amtDue;
}
info "Amount Due: " + amtDue;
}
// end of foreach
}