This time around I have to turn a previously written code in a function and call the function in the code. I am having a problem when referencing my label box and can't seem to find an answer. Here's the code:
private void btnEndSale_Click(object sender, EventArgs e)
{
dblGrandTotal = dblSubtotal + dblTaxTotal;
lbxTally.Items.Add("");
lbxTally.Items.Add("");
lbxTally.Items.Add("Subtotal: " + dblSubtotal.ToString("C"));
lbxTally.Items.Add("Tax Total: " + dblTaxTotal.ToString("C"));
lbxTally.Items.Add("Grand Total: " + dblGrandTotal.ToString("C"));
}
and here's what I'm trying to turn it into:
static void PurchaseTotal(ref double dblSubtotal, ref double dblTaxTotal, ref double dblGrandTotal, object lbxTally)
{
dblGrandTotal = dblSubtotal + dblTaxTotal;
lbxTally.Items.Add("");
lbxTally.Items.Add("");
lbxTally.Items.Add("Subtotal: " + dblSubtotal.ToString("C"));
lbxTally.Items.Add("Tax Total: " + dblTaxTotal.ToString("C"));
lbxTally.Items.Add("Grand Total: " + dblGrandTotal.ToString("C"));
}
So that I can just use:
private void btnEndSale_Click(object sender, EventArgs e)
{
PurchaseTotal()
}
I'm getting a little lost as to how to reference the object label box (or if I need to?) and if I need to reference my variables again in the PurchaseTotal function when I call it. Any help is appreciated! Thanks!
PurchaseTotalmethod in another class?