| Visual basic programming?

Visual basic programming?

boss.checker asked:


Using 2005 vb -I want to declare variables as numbers, but I only want to show the number to two decimal places (£5.23 for example). How would I go about doing this?

any help would be greatly appreciated

Related posts:

  1. Visual Basic Programming Help? michbox asked: okay i created a simple income calculator but...
  2. Trouble Writing a basic program with Visual Basic 2005 Express? dconverse2 asked: A motorist wants to determine her gas mileage....
  3. Really Challenging Visual Basic Question Problem? ABC asked: I have a little problem. I need to...
  4. computer programming Visual Basic tutorial? John P asked: Can anyone show me how to work...
  5. Can you give me the code for a cool program for Visual basic 2008? spongebob asked: Ok i got visual basic 2008 express edition...

Filed Under Programming & Design |

Tagged With , ,

Comments

2 Responses to “Visual basic programming?”

  1. jaden404 on May 16th, 2009 4:23 pm

    Try this:

    Dim int As Single = 1111.11
    Dim strlnt As String

    strlnt int.ToString(’£###,###.00′)

  2. Mehdi on May 17th, 2009 7:26 pm

    You declare the number as a Double, and when showing it, you use FormatCurrency, FormatNumber, or the simpler Format function.

    FormatCurreny inserts the monetary symbol based on your computer settings, but acts the same as FormatNumber; FormatNumber allows you directly state the number of digits after the decimal; Format requires manually setting the, well… format:

    amount = Format ( nrVar, “$#0,00″ )
    amount = FormatCurrency ( nrVar, 2, true )
    amount = “$” & FormatNumber ( nrVar, 2, true )