VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,768 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
decTotalCost = intNumDays * decLocationFee + decRegistrationFee
lstCost.Items.Add(decTotalCost).ToString("c")
in the statement above, the right amount is sent to lstCost, but not as a ("c") or a decimal, any suggestions?
Is this what you want? Note how I've done the format without ToString.
private void button1_Click(object sender, EventArgs e)
{
int intNumDays = 8;
decimal decLocationFee = 23.77m;
decimal decRegistrationFee = 12.99m;
decimal decTotalCost = intNumDays * decLocationFee + decRegistrationFee;
lstCost.Items.Add($"{decTotalCost:C}");
}
Hi @Hekzdaddy ,
the right amount is sent to lstCost, but not as a ("c") or a decimal,
Change :
lstCost.Items.Add(decTotalCost).ToString("c")
To:
lstCost.Items.Add(decTotalCost.ToString("c"))
Best Regards,
Jack