Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

I am using VB.NET windows application 2005 with MS Access.

I want to add 2 decimal point in text box control for currency.
eg. If I enter 12 in tetbox it display 12.00 or if I enter 12.20 then it display 12.20.

I searched for it but I didn't understand the answer they have given.

Please can anyone can tell me how to do it with small example?

Thanks
Posted
Updated 22-Jul-10 21:37pm
v2
Comments
Dalek Dave 23-Jul-10 3:37am    
Edited for Readability, Syntax, Spelling and Grammar.

TextBox1.Text = Format(Val(TextBox1.Text), "#0.00")
 
Share this answer
 
Quite easy.

Define the content as a double.
Then convert to a Fixed 2 string.

example...

Dim dblEntry as Double
dblEntry = TextBox1.Value
TextBox1.Text = dblEntry.ToString("F2")


Should do the trick
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900