how to remove numbers after decimal point

hi, i need help , i had to do a program , but i'm stuck in this thing, the answer comes out as for example 17.79, i want to just choose 17 and ignore the rest... how can i do that , i tried many things but still :( please help .. thanx
11/20/2005 12:16:07 AM 91979 articles. 3 followers. Follow

7 Replies

Similar Articles

[PageSpeed] 8

Jsut convert it to an int and it will automatically truncate the decimals.  For instance if the 17.79 is in a variable called result, just do something like this.

int i = (int)result;   // in C#

In VB it;s a bit more complex because explicit conversion would round, so your 17.79 would be rounded to 18. so you need to something more like this

Dim i As Integer
Dim result As Double = 17.79
result = Math.Floor(result)
i =
CType(result, Integer)

My Blog:
11/20/2005 11:11:41 AM

but what do I do if I want to remove only certain floating points, for example:

Dim b As Decimal = 897.23452345

I want to make it 897.23

but don't wish to use FormatCurrency as it adds $ and I don't want it.

11/19/2008 12:24:10 AM


Dim a = 897.23452345
Dim b = FormatNumber(a, 2)


thanks anyway

11/19/2008 12:27:43 AM


It can be done as follow:


double piValue = Math.PI; //Sample value of double data type
int truncatedValue = ((int)piValue);

Hope that helps :)

If the answer/reply above helped you, please mark the question as answered. Thank you. =^^=
11/19/2008 1:37:56 AM


I still want to be left with 2 zeros.

look at my question & my answer (the type of the returned value is not impotant for me so a string is good too).

thanks anyway

11/19/2008 2:27:04 AM

if us need string to show this then use .ToString("N2")

this also present comma, and2 for 2 digits 

We All move to our original place.
Don't forget.

Imran Baloch
11/19/2008 5:44:43 AM

Following code may help you:

Float num = 17.79;

String num1 = null;

num = math.Round(num,0); OR

num1 = num.Tostring();

Either of them will provide you the desired result..

Have a nice day.

11/19/2008 6:10:15 AM

Similar Artilces:

inserting a decimal number to stored proc. with decimal parameter
I'm trying to enter large number 99999999, (8 digits) converting to decimal in .NET, then using that as a parameter in stored proc. which has a decimal type (decimal(15,2) as a parameter. C#:if (txtAnnualizedSaving.Text.Trim() != string.Empty) {try { sdata.AnnualizedSaving = Convert.ToDecimal(txtAnnualizedSaving.Text); // only for testing ....scale = (System.Decimal.GetBits(sdata.AnnualizedSaving)[3] >> 16) & 31; }catch { sdata.AnnualizedSaving = 0; } }   ... In the business object I have the following code:private bool UpdateData() {bool ret = false; try ...

VB.NET: How to convert hexadecimal number to normal (decimal) number?
Hi to all VB.NET function Hex() converts numbers to hexadecimal strings, is there any reverse function that converts hexadecimals back to numbers?? Thanks, Hooker Hi, how are you? In C#, we have something like: Convert.ToInt32(string strValue, int Base)... So I basically can do: Int iDecimal = Convert.ToInt32("AF8", 16); I'm pretty sure there must be something like it on VB.Net. Hope this Helps, Covo"Everything should be made as simple as possible, but not simpler", A. Einstein That should work, thanks. I'm fine, BTW...

Removing decimal points
Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. On Jun 8, 2007, at 9:52 PM, ash wrote: > I need to remove decimal points from numbers. For eg 1.23 or 1.77 > would be just 1. Any suggestion is appreciated. Thank you. Use de int() function. -- fxn ash wrote: > Hello there! > > I need to remove decimal points from numbers. For eg 1.23 or 1.77 > would be just 1. Any suggestion is appreciated. Thank you. > > > perldoc -f int int EXPR int...

How to validate a decimal value with 2 digits after decimal point (de decimal point is a comma)
  I am a newbee, I have a Textbox where de user must write the price of an object. How can I validate de data entry in the Textbox (it must be a valid decimal with 2 digits after decimal point), and my pages are in  Portuguese so the decimal point to be accepted must be a comma   thanks  well you can do something like followig:  suppose TextBox1.Text = 123456,789 then you can say if(TextBox1.Text.Contains(",") ) {     int index1 = TextBox1.Text.IndexOf(",") +1;     int index2 = TextBox1.Text.IndexOf(...

how to get a numbers after decimal?
i have this number 3.01 how to get .01 from this number any function ? thanxbeginner ASP.NET Here are a couple approaches: f = n - CInt(n) f = n Mod 1 Tim McBrideThis posting is provided "AS IS" with no warranties, and confers no rights. thank youbeginner ASP.NET ...

How to remove the decimal point ?
A simple question.I am working with c# and I a have a variable with .00 (ex: 500.00).I would like to convert this variable to 500Bottom line: to remove the .00Someone know what do I have to write ? Try:FormatNumber(Myvariable, 0)--------------------------------------------------------Don't forget to click "Mark as Answer" on the post(s) that helped you.NHibernate with Problem-Design-Solution sample applicationScott blog  This is working  TextBox1.Text = String.Format("{0:0.##}", 123.00);   Mark as Answer if the p...

how to get start with .NET
the net help people installed  to my desktop 1-microsoft visual studio .NET enterprise developer 2003 2-microsoft .NET framework 1.1 what else do i need ...???  and how can i try with some simple code in VS.Net and run it to see wat happen...????? please help If you want to develope web applications, then you'll also need IIS on your PC.  That'll require XP-Professional or Windows 2000/2003, but XP-Home edition won't allow IIS installation. As for how to get started, you can search the web for some tutorials or buy a good book on VS.  The topic is way too vast to...

Getting Start With .net
hi i'm intersted to learn (vb or delphi) . i programming with delphi6 but i'd like to tp know something about programming in internet specially with .net . i hear about with delphi 7 that i can programming with delphi in .net .... is it right ? what 's our opinian about it ? and better to learn Vb.Net or continu with delphi(or thanks. Ali Darabian I think there is some support for Delphi in .Net. However, you will find much more support from the user community if you choose a more popular language such as VB.Net or C#. Since your al...

Where to start and how did you get started?
Hi, I have had a feeling for a long time to jump into the adds market for some time due to my low income (shooting for the stars) and I don't have anything better to do these days. But I find it really difficult not to give up due to lack of guides (what I can find atleast) and all the hard words which only makes me confused. But I won't give up. Never. Not sure if this is the right place to post this, but I deffinitly would be really greatfull for help getting started. How did you get started? +If there are any teacher that wanna show me the ropes private, I can give payment with ...

Getting started with JScript.NET
I'm a Javascript and Actionscript developer, and the thought of being able to do server-sides in something I know was too good to resist. Does anyone know some good tutorials for developing ASP.NET pages in JScript?  I can find lots of console code, but simple things are hard: like I can't even figure out how to print something out to the web page (just a string). What I'm really trying to do is access a database, verify a login, and print JSON out to the response.  What should I do to start?  Is there a better way to do this? (IE: using some JSON library already?). I'm commun...

Adding Numbers with decimal points
I have been trying to add a group of textboxes together and display as a whole number with two decimal space  ...  ie 1458.35. I have been converting the textbox.text string to an integer and adding the results with a Math.Round function but it doesn't work (see below). I used the exact same code on a major project two years ago and it worked fine. I am using the (ByVal d As Decimal, decimal As Integer) As Decimal function  The code is: <  Dim num as Integer num = Textbox1.Text Dim num2 As Integer num2 = Textbox2.Text Dim num3 as Integer num3 = ...

Getting started .net website
Hi folks,Does anyone here know of a good website to just sit back and read for learning .net? Thanks in advance.Baldeep Right here... Click the Get Started and Learn sections here. Quite a few out there - - this one, has a lot of good videos -  also, but then, I might be a little prejudiced David WierMCP/ - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(P...

Getting Started with .net and a few questions
Hello I've done some asp and php programming along with various other languages in the past and slowing getting my head around .net.I have a small project of creating a Holiday Booking system on our Intranet and just trying to get the first part to work properly will hopefully get me sorted for the whole project. The Intranet is running on .net 2 and I prefer to use the VB code rather than C#. This is connecting to an SQL server.My initial page that I am trying to create is just for an admin user to view which dates in a table have been specified as Bank Holidays and be able to add ...

Get start with Share Point
Hi friend's     Some body can help me, I am beginning with Share Point. I have a Share Point Portal and I need upload files into a Document Library How can I do? Greetings.  Hi kyddyan,Do you want to do the upload programmatically or not? You can do it this way:Go to your document libraryOn the right top of your document library you have a "View" dropdownlist.Change the view to: "Explorer View"Now open a Windows Explorer and drag the folder you want to upload to the "Explorer View" of the Document Library.Kind regards,Wim Pl...

Web resources about - how to remove numbers after decimal point -

Number - Wikipedia, the free encyclopedia
A number is a mathematical object used to count , label, and measure . In mathematics , the definition of number has been extended over the years ...

Number - Wikipedia, the free encyclopedia
A number is a mathematical object used to count , label, and measure . In mathematics , the definition of number has been extended over the years ...

'Significant Number' Of Harper Patronage Appointees Have Offered To Resign: Liberals 122
The appointments were made in the last days of the previous Conservative government.

Return of investment for cybersecurity: Can we put a number on it?
... to make money in order to pay salaries (including salaries of the cybersecurity team), so their point of view, based mainly on financial numbers, ...

Here are Amazon's cute holiday sales figures translated into real numbers
Amazon is notoriously tight-lipped about the details of its business. It took years before the company revealed the size of its cloud business ...

Wild ride: China markets by the numbers
For investors who couldn't bear to look, here are the giant slides and huge gains on the wild ride that was investing in China.

2015: By The Numbers
... what with last year’s GM recall, Sony hack, and the like — we still had rather a lot go on in the last 365 days. Here’s a run-down of the numbers ...

We Will Increase The Number of Substitutes By Paying Them Less
And giving the rest to a private company, of course. I think it's cute that anybody pretends that the plan was supposed to succeed.

FIRST LOOK: Kylie Minogue Strips Joshua Sasse Down in Sexy, New 'Galavant' Number
ETonline has your first look at the singer, who is adding her star power to the new season of the ABC musical.

Your Holiday By The Silly And Surreal E-Commerce Numbers
Quantifying holiday cheer: 673,000 Beatles playlists, one box of Stove Top stuffing, and a 20-fold search increase for "return policy." Christmas ...

Resources last updated: 1/2/2016 5:06:21 AM