![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Convert Formatted Double Into String I have a double stored in a DataTable: dt.Rows(i)(MergeFieldName) I want to format this and store it into a string. I have formatting stored in a database, such as "$#,##0.00" How do I use this formatting, apply it to dt.Rows(i)(MergeFieldName), which is a double, and then store it in a string? So if the value of dt.Rows(i)(MergeFieldName) is 14,122.05. I would get $14,122.05. Derek |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Convert Formatted Double Into String "Derek Hart" <derekmhart@xxxxxx> schrieb Quote: > I have a double stored in a DataTable: dt.Rows(i)(MergeFieldName) > > > > I want to format this and store it into a string. > > > > I have formatting stored in a database, such as "$#,##0.00" > > > > How do I use this formatting, apply it to > dt.Rows(i)(MergeFieldName), which is a double, and then store it in > a string? > > > > So if the value of dt.Rows(i)(MergeFieldName) is 14,122.05. I would > get $14,122.05. What's the format of the format? I guess it's one of these:http://msdn.microsoft.com/en-us/library/427bttx3.aspx Example: dim fmt as string = "$#,##0.00" dim s as string s = directcast(dt.Rows(i)(MergeFieldName), double).ToString(fmt) Armin |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Convert Formatted Double Into String As long as the type you're trying to format is a numeric data type the formatting will work just fine. However, if you're trying to take a string type that contains numeric data you will need to parse it to the appropriate type before you can format it. Example A: Dim s As String = "1234.44" s.ToString("$#,##0.00") Will not work. Example B: Dim d As Double = Double.Parse("1234.44") d.ToString("$#,##0.00") Will work properly. "Armin Zingler" wrote: Quote: > "Derek Hart" <derekmhart@xxxxxx> schrieb Quote: > > I have a double stored in a DataTable: dt.Rows(i)(MergeFieldName) > > > > > > > > I want to format this and store it into a string. > > > > > > > > I have formatting stored in a database, such as "$#,##0.00" > > > > > > > > How do I use this formatting, apply it to > > dt.Rows(i)(MergeFieldName), which is a double, and then store it in > > a string? > > > > > > > > So if the value of dt.Rows(i)(MergeFieldName) is 14,122.05. I would > > get $14,122.05. > > What's the format of the format? I guess it's one of these:> http://msdn.microsoft.com/en-us/library/427bttx3.aspx > > Example: > dim fmt as string = "$#,##0.00" > dim s as string > > s = directcast(dt.Rows(i)(MergeFieldName), double).ToString(fmt) > > > Armin > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Convert Byte() to string | VB Script | |||
| Convert to & from base64 String | PowerShell | |||
| convert int to numeric (formatted) string | .NET General | |||
| convert array of strings to string | PowerShell | |||
| here-string with single and double quotes | PowerShell | |||