FlyBoy Posted September 16, 2004 Posted September 16, 2004 i want that the string (number) which the user inputs gonna convert to a currency format , anyone knows how i should do it? for e.g: dim str as string = "" str=textbox1.text str=str.tostring("C") doest work :( lets say the user input is 12000 i want to convert it to 12,000 anyway to do it? Quote
Administrators PlausiblyDamp Posted September 16, 2004 Administrators Posted September 16, 2004 You will probably need to convert the string to a numeric format first - then format it up as a currency string. Dim s As String = "120000" Dim d As Decimal = Decimal.Parse(s) MessageBox.Show(d.ToString("C")) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
FlyBoy Posted September 16, 2004 Author Posted September 16, 2004 well thanks for that ... oh and btw...i never knew what the .Parse function is for? Quote
Leaders Iceplug Posted September 16, 2004 Leaders Posted September 16, 2004 i never knew what the .Parse function is for? A question? The .Parse just converts it into a numerical value. So, it goes from the text "120000" to the actual number 120000, using Parse. Much like the Convert.ToDecimal() function. Then, the actual number is converted back to string with currency settings. Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
FlyBoy Posted September 16, 2004 Author Posted September 16, 2004 A question? The .Parse just converts it into a numerical value. So, it goes from the text "120000" to the actual number 120000, using Parse. Much like the Convert.ToDecimal() function. Then, the actual number is converted back to string with currency settings. so i can use the convert.todecimal or Cdec right? so what are the diffrences between them? i mean why i should use parase rather then Cdec? 10x for the answer Quote
Administrators PlausiblyDamp Posted September 16, 2004 Administrators Posted September 16, 2004 I tend to use .Parse when converting from strings as it can give you more control over what format the input can be in - it will cope with currency, decimals, thousands seperators, hex, whitespace etc. If users are typing in these values you never know if they will try to be a bit clever and put these things in. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.