Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting String to 2 Decimals

Status
Not open for further replies.

sonya9879

Programmer
Jun 18, 2004
147
0
0
CA
Hi,

I know this is probably something really really simple but anyway, I have spent 2 hours already without any luck.

I have the following:

Dim tra_amount = "1234"

And I want to convert to 12.34

I tried the following:
CInt(tra_amount)
String.Format("{0:c}", Double.Parse(tra_amount))

and also I tried
Convert.ToDouble(tra_amount)

I still end up with 1234 and not 12.34.
Basically I need to say that the last 2 digits will always be 2 decimals. How I can do that fast and nicely?

Thanks :)
 
Thanks PankajBanga and JohnYingling for your help. Both solutions works just fine but I think I will use PankajBanga solution this time. But thanks so much to both of you for helping me on this small problem... :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top