need help with formatting a decimal number

I have a field that is stored as a float in the database and I have to divide it by 3 when

I display it back to the user sometimes I get this:
How do I format it so it is two decimals or maybe even just drop the decimal all together?
Either of these is what Im after: 119.3, 19.33, or 119.
Please help.
4/13/2004 3:31:11 PM 93655 articles. 5 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 51

Change for your culture and number of decimal places:

// Gets a NumberFormatInfo associated with the en-US culture.
NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat;
// Displays a negative value with the default number of decimal digits (2).
Decimal myDec = 119.33333333;
Console.WriteLine( myDec.ToString( "N", nfi ) );

Darrell Norton, MVP
Darrell Norton's Blog

Please mark this post as answered if it helped you!
4/13/2004 4:55:32 PM
Thank you Darrel.

This also worked for me.
Decimal.Round(somevalue, 2)
(rounded to two places)
4/13/2004 5:17:37 PM
I didn't know if you wanted it rounded or not, so I put up the way where the decimal value did not change yet displayed a "rounded" amount.  But if it works, don't fix it!
Darrell Norton, MVP
Darrell Norton's Blog

Please mark this post as answered if it helped you!
4/13/2004 7:53:17 PM
Hi! Sorry if i'm dumb but how can you do these in ASP.NET using VB Language? Thanks!
I'm an old timer in Classic ASP but a newbie on ASP.NET, so please help me out. Thanks in advance
9/3/2007 10:31:26 AM

Similar Artilces:

Really need help with disabled web forms in visual 2003
Hi, I've posted in the ASP.NET forum as someone suggested, but I got no response and am still unable to use the software. In Visual Studio .NET 2003, with .NET Framework 1.1, all web form controls (in fact all controls in the toolbar) are disabled. I create a webform.aspx page, I AM in design view, but when I go to the "web forms" toolbar, I cannot drag anything to the page because all the controls are disabled (the toolbar is visible, just everything within it is disabled). I solved this last time by completely wiping my drive and spending three days reinstalling and updating everythin...

Need HELP with adding a System.Windows.Forms control to web form!
Howdy folks. I'm in need of some help. I wanted to add a nifty little Control I made for a Windows Form to an ASP.NET page. Now I went and saw Microsoft's quickstart tutorial, and followed the example... You know, compile it to .dll... blah, blah, blah, then use the <OBJECT> tag to insert it into the page. Well, I did all that... the control downloads... but I can't see a thing! :'( For example, here's some code ~ using System; using System.Windows.Forms; using System.Drawing; using System.Reflection; [assembly:AssemblyVersion("")] ...

help needed with Web forms
I am new to Web Application so please bear with me. I have a application where i have 2 3 web forms. I want to have a Page which will have link to these webforms and when user clicks on this the webform will open in the same page. It will be similar to frames where 1 frame have menu or links to these webforms and 2nd frame will open these webform when link is clicked. Could some one provide the easy code for this.  Thanks. This can be done by Master page, please take a look here Kaiser, MCTS, MCPPlease Mark As Ans...

Need help with web forms
Hi,I am trying to make a web form that kinda works like the windows dataform.  I want to be able to take information from my table and display things in labels and textboxs, but have been having difficulty figuring out how to do this.  Does anyone have a suggestion of how I could make such a form that would be able to add new records, update records, delete records, or even make some inactive?  I also may need to show other related tables according to what the user is doing.  Say you are viewing a customer, so you want to be able to see all of that customers information, ...

need help for web form
I have a one web form has two datagrid (master and detail)I have a master datagrid inside panel so i can have scroll bar. <asp:Panel ID="pnlsummarys" runat="server" Height="320" Width="100%" ScrollBars="auto"><asp:DataGrid ID="grdsummary" runat="server"><HeaderStyle BackColor="#42468E" Font-Bold="True" ForeColor="#F7F7F7" CssClass="ms-formlabel DataGridFixedHeader" /> <style type="text/css"> .DataGridFixedHeader { POSITION: relative; ; margin-top: 100px; TOP: expression(this.offsetParent.scrollTop); BACKGROUND-COLOR: white }</style> I use this styly sheet...

Need Web Form Help!!!
Ok here goes, I need to create an admin form that contains a list of events. This list, I was thinking about using a listbox, but the form needs the ability to select specific events and move them to another listbox. This new list will have to be saved in some way and then be displayed the next time the page is visited. Any ideas of how to accomplish this? Thanks in advance Brian That's a general question, so I'll provide you with a general answer. Create your two listboxes, one that is populated from the database and a blank one. The ideal solution here would be to move your items ...

Decimal numbers in WEB form
This is a multipart message in MIME format. --=_alternative 0047647BC12573A3_= Content-Type: text/plain; charset="US-ASCII" I have column Decimal(2) in datawindow. In development env. (Windows XP) there is e.g. number 34.51. After deployment to Window Server 2003 number is 3451,00. Any advice ? Thanks Miroslav. --=_alternative 0047647BC12573A3_= Content-Type: text/html; charset="US-ASCII" <br><font size=2 face="sans-serif">I have column Decimal(2) in datawindow. In development env. &nbsp;(Windows XP) there is e.g. number 34.51.&...

Need to prompt client with Print Dialog from IE; need some format to print web form content
Have you ever been on a website, and it will have a link or button to "Print Something", and when pressed, the Windows print dialog will automatically appear?  Well that is what I need to do.  I am guessing it must be some Javascript or something in .NET to do this.  So here are my questions. 1. How do I show the user a print dialog box from IE when they click on a link or button on my ASP.NET page? 2. The content I want to print is just a long set of instructions in an ASP.NET text box.  What would be the best product/format to put this in that can ...

Help needed in designing web forms
Hello ,I am a starter in ASP.NET , I am trying to build a web page that is similiar to the config screen of a router .What I am doing is basically build a web page that connects to a server and retrieves data to and from it .My problem is in the design of the web form . I want to create vertical tabs and when I press them the screen changes . My problem is that the controls I add go one under another and not one next to another . The tabs I have created using Menu and Views .  I tried placing Panels and still had no luck . Basically I don't know how to build it well .I am using...

Need Help with Web Cam in .net
Hi everyone. First time on this forum. Thanks for any advice!I am looking for a good .net component for webcams.I need one that can allow two feeds at once, so people could see each other, ie. I can see the person I am talking to, and visa versa. Anyone know of any good .net components for webcams?Thanks!...

Need help with form entry format
I am working in the following enviroment, please limit your answer to this: Visual Expres Web Development with Visual Basic. One of my forms have a multiline textbox and its entry is save into a database. When the end user write anything, he would like to keep the same imput format. Like a margin, a blank line, etc. However, when information is retrieved from database, all this format is lost, and everything come up in a big paragraph.Without the original format it is hard to read specially when the paragraph are too long. What should I do in order to keep the same format throug...

BMI Web Form need help
Edited by SomeNewKid. Please post code between <code> and </code> tags. I have create a BMI web form from a tutorial, and am having trouble getting the output right. Here is the code I used with two text boxes and a submit button: ----------------------------------- Sub btnSubmit_Click(sender As Object, e As EventArgs) 'find out person's height and weight Dim h as Integer = height.Text Dim w as Integer = weight.Text 'Calculate the person's BMI Dim BMI as Double BMI = (w / (h * h)) * 703 'Output the BMI value Response.Write(*Your BMI is * ...

Need help creating web form.....
Hi, I need some assistance creating a web form. To be more specific, I want to create a form with one "text" field and a submit button. I need the text entered in the "text" field to be inserted into a table located in a database I have setup when the user clicks on the "submit" button. Can somene help me out on getting this configured correctly? I've searched for examples and tutorials on how to do this, but couldn't really find anything helpful. Thanks, Derek Have a look at the video tutorials on the "learn" section of this website...Ke...

need help on login web forms
hi i am making a access database driven site and thing i want to ask is when entering this : If User.Identity.IsAuthenticated Then ' Logged In Else ' Not Logged In how do a display a image if someone is logged in and a differnet image if they aint logged in. thanks Use asp:image and set ImageUrl: <asp:image id="MyImg" runat="server"></asp:image> If User.Identity.IsAuthenticated Then MyImg.ImageUrl = "../imgs/img1.jpg" Else MyImg.ImageUrl = "../imgs/img2.jpg" ...

Web resources about - need help with formatting a decimal number -

Wikipedia:Manual of Style/Text formatting - Wikipedia, the free encyclopedia
The most common use of boldface is to highlight the article title, and often synonyms, in the lead section (first paragraph). This is done for ...

Formatting « Above the Law: A Legal Web Site – News, Commentary, and Opinions on Law Firms, Lawyers ...
Above the Law: A Legal Web Site – News, Commentary, and Opinions on Law Firms, Lawyers, Law School, Law Suits, Judges and Courts

Android Studio 1.2 Reaches Beta, Adds Built-In Decompiler, Inline Debugger Variables, Smarter Formatting ...
When Android Studio v1.1 entered the Stable channel, about 6 weeks ago, the Dev Tools team gave word that v1.2 was already well underway and ...

TextExpander 2.0 Brings Rich Text Formatting, Fill-In Snippets And More
TextExpander has finally received its big 2.0 update.

WordEver HD - Text Editor with Redesigned Keyboard and MarkDown syntax & formatting highlight
Holen Sie sich „WordEver HD - Text Editor with Redesigned Keyboard and MarkDown syntax & formatting highlight“ im App Store. Sehen Sie sich Screenshots, ...

Macs are vulnerable to Thunderstrike 2 firmware malware that survives formatting
... Thursday, researchers will demonstrate that not only can Macs be remotely infected with malware, but that this malware can survive a user formatting ...

16 Tips on Blog Writing and Formatting
... again. My point is that you ought to take advice with a grain of salt. And that applies to this post as well. Writing blog posts and formatting ...

Select Text With Similar Formatting in Google Docs
Google Docs added a cool new feature that lets you select all the text with similar formatting, so you can quickly make some changes. It's like ...

Resources last updated: 11/23/2015 2:33:33 PM