Prev: Vb.net 2008 ContextMenuStrip logical error when running code
Next: Eliminate / Hide the Form's Title Bar
From: mp on 17 Mar 2010 18:56 Trying to use the format method in vb.net to oconvert a double to string of 4 places I tried: Format(CStr(dHeightOfStone), "x.xxxx") and: Format(CStr(dHeightOfStone), "#.####") It returns "x.xxxx" or "#.####" instead of "36.1875" (or whatever number was input) any tips? thanks mark
From: Armin Zingler on 17 Mar 2010 19:09 Am 17.03.2010 23:56, schrieb mp: > Trying to use the format method in vb.net > to oconvert a double to string of 4 places > > I tried: > Format(CStr(dHeightOfStone), "x.xxxx") > > and: > > Format(CStr(dHeightOfStone), "#.####") > > It returns "x.xxxx" or "#.####" instead of "36.1875" (or whatever number was > input) > > any tips? These format strings are for formatting numbers. You are trying to format strings because, before, you've converted the numbers to strings using the CStr function. Try this instead: dHeightOfStone.ToString("#.####") -- Armin
From: Family Tree Mike on 17 Mar 2010 19:10 On 3/17/2010 6:56 PM, mp wrote: > Trying to use the format method in vb.net > to oconvert a double to string of 4 places > > I tried: > Format(CStr(dHeightOfStone), "x.xxxx") > > and: > > Format(CStr(dHeightOfStone), "#.####") > > It returns "x.xxxx" or "#.####" instead of "36.1875" (or whatever number was > input) > > any tips? > > thanks mark > > > > I believe you want to use Format(dHeightOfStone, "#.####"). Frankly, I prefer dHeightOfStone.ToString("f4"), but that's just my style... -- Mike
From: mp on 17 Mar 2010 19:19 ok, even though the help files show the order i first tried, > Format(CStr(dHeightOfStone), "#.####") i tried the opposite order > Format( "#.####", CStr(dHeightOfStone)) now instead of getting "#.####" returned, i get 4.62500000000364 so it's still not formatting what am i missing? as an alternative i tried using round Dim sWidthLiner As String = CStr(Decimal.Round(Cdec(dLengthOfMoldSidesLiner), 4)) but it seems a long way around to just get a double rounded to x places and converted to string thanks mark "mp" <nospam(a)thanks.com> wrote in message news:Oh0AcUixKHA.2644(a)TK2MSFTNGP04.phx.gbl... > Trying to use the format method in vb.net > to oconvert a double to string of 4 places > > I tried: > Format(CStr(dHeightOfStone), "x.xxxx") > > and: > > Format(CStr(dHeightOfStone), "#.####") > > It returns "x.xxxx" or "#.####" instead of "36.1875" (or whatever number > was input) > > any tips? > > thanks mark > > > >
From: mp on 17 Mar 2010 19:31 Thanks Mike and Armin, "Family Tree Mike" <FamilyTreeMike(a)ThisOldHouse.com> wrote in message news:uVVEMcixKHA.5036(a)TK2MSFTNGP02.phx.gbl... > On 3/17/2010 6:56 PM, mp wrote: >> Trying to use the format method in vb.net >> to oconvert a double to string of 4 places >> >> I tried: >> Format(CStr(dHeightOfStone), "x.xxxx") >> >> and: >> >> Format(CStr(dHeightOfStone), "#.####") >> >> It returns "x.xxxx" or "#.####" instead of "36.1875" (or whatever number >> was >> input) >> >> any tips? >> >> thanks mark >> >> >> >> > > I believe you want to use Format(dHeightOfStone, "#.####"). > > Frankly, I prefer dHeightOfStone.ToString("f4"), but that's just my > style... > > -- > Mike
|
Next
|
Last
Pages: 1 2 Prev: Vb.net 2008 ContextMenuStrip logical error when running code Next: Eliminate / Hide the Form's Title Bar |