Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

format data in listbox VB.net?

i'm creating a program for school that had you choose between three different options for an internet service provider. The output will be the cost of the package you selected in a text-box, as well as how much you would save with the other packages in a list box. I think I almost have it figured out but the text in the list box comes out wrong. the answer will come out as -20.000000004. I need the number to appear as $20.00, is there anyway to do this? I appreciate the help!

here is where I assign the items to the list box

lstDisplay.Items.Add(dblSavingsB - dblTotal)

1 Answer

Relevance
  • 7 years ago
    Favorite Answer

    Try the following

    lstDisplay.Items.Add((dblSavingsB - dblTotal).ToString("$#.00"))

    TexMav

Still have questions? Get your answers by asking now.