convert to integer without rounding a number

Hallo,i have a simple question:
Lets say i have a decimal, 1.7 for eg and i want to convert it to integer,but WITHOUT ROUNDING THE NUMBER.
So i tryed many different aproaches to do this but all failed, just the example below.
I get a integer 2 instead of 1 so that means the number is rounded.
If somebody knows how to do the same thing but without rounding the number please let me know

Sub Page_load()
           Dim d As Double
           d = 1.7
           Dim i As String
           i = Convert.ToInt32(d)
           Response.Write("Integer value is" & i)
       End Sub

Free Web Hosting - My website
3/5/2006 10:42:15 PM 91979 articles. 4 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 41
Get it on Google Play
Get it on Apple App Store

Use Math.Floor() on your double.


Dim d As Double = 1.7
Dim i As Integer = CInt( Math.Floor( d ) )

This will return the value of 1.


3/6/2006 12:14:43 AM

Similar Artilces:

Getting Started Without VS.NET
Hi all, does anyone know how any online resources that can show me how to create web apps that include code-behind, and uer controls without using VS.NET? I have VS.NET in work, but would also like to do work at home, but cannot install VS.NET on my home laptop because I simply dont' have the space or processor power. Any online articles would be welcome, as will any open-source apps - I currently have SharpDevelop, but I find it unstable as it crashes my laptop alot of the time. Thanks Tryst Did you try Web Martix? It is a FREE tool from Microsoft.Regards, Narayana ...

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...

Convert number to integer
Right now I have a form that has people enter there numbers, I do some calculations and then send the projections back to them. In the form I have them enter the value without commas. I would like to make easier for people by letting them enter their values with commas (i.e. 20,000). How do I filter out the commas so that I have just the numeric value? I have to be able to evaluate thousand and millions, no decimal values. cheers; Hi there, this really isnt to difficult, you should be able to do something like this cint(replace(num, ",","")) Set your input variable to be a string, the c...

Converting classic to .NET 2 code, and .NET gets an error back from ADS?
 For future-proofing, our Internal Phone Directory is being moved onto our AD servers, and obviously we're using LDAP for queries.To get the phoneboook queries working, I adapted the current classic ASP code to use LDAP, and that works fine. However, we're wanting to move these pages to .NET, and that's where the problem comes in. Using the same basic logic from the Classic code (90% of its unchanged) to produce an LDAP query, I get the error  155 Unknown error (0x80005000)This is using the same website, and so the same credentials  - unless aspx pages run und...

used a to converter and am now getting a syntax error.
ok I used a cool utility at to convert some to and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

Rounding numbers in .NET
Hi, I take in a value like 17499.99 in my app. I want to round this up to the nearest thousand So above should be 18000. Even if I have a value like 17001 I want to round up to 18000. Anyone know how I can do this? I have tried using the Math class but it does not do this for me. If i round 17499.99 using Math.Round it gives me 17500 but I want to get 18000. Once it is anyway over 17000 I want to round it to 18000. Thanks, C. Hey COG, Try something like this: 1) Take the number and divide by 1000 2) Round that number to the nearest integer (using Math.Cei...

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 ...

converting a string to number or integer
erm... how is this done in c#? or convert an object to and number or integer? I need to get the below as a number or int: TotalRecords = conSelProdCount.ExecuteScalar().ToString(); So i can use it in: ProductItem[] arrNews = new ProductItem[TotalRecords]; int rwcnt = 0; while ( dtrProducts.Read()) { string NewVar = dtrProducts["ProductName"].ToString(); arrNews[rwcnt] = new ProductItem(); arrNews[rwcnt].rowcount = @TotalRecords; arrNews[rwcnt].ProductName = dtrProducts["Pro...

How do I prevent numbers from getting rounded?
Hi, I'm multiplying two number -- both coming from a DataTable -- but the result is rounded. How do I prevent this? Here's my code: row["ExtendedPrice"] = Convert.ToDouble(row["RetailPrice"]) * Convert.ToDouble(row["Quantity"]); I have $49.80 as the retail price and quantity is 3. Result, I'm getting is $149Thanks,Sam What type is row["ExtendedPrice"] ?  If it's an integer, then it doesn't matter whether you convert the RetailPrice and Quantity to doubles. Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!...

Prevent Number From Getting Rounded
A Web Form has a TextBox within a DataGrid wherein users are expected to enter only whole numbers.  It should be validated so that the TextBox doesn't remain blank or any non-numeric data is entered in the TextBox. If the TextBox doesn't get validated I want to display messages to the user which should be as precise as possible for the user to easily identify where he erred. This is how I did it:If (CType(ea.Item.Cells(4).Controls(1), TextBox).Text = "") Then    lblMessage.Text = "Quantity cannot be blank"Else    If Not (IsNumeric(CType(ea.Item.Cells(4).Con...

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...

integer division without rounding
Hi Everybody, how can I do an integer division without rounding? e.g x=41, y=60 z=x/y=0.68 but it rounds it upto 1 but what I want is 0. How can I do it in  devmetz: I think this is what you are looking to do:  Dim x As Decimal Dim y As Decimal Dim z As Integer x = 41 y = 60 z = Math.Floor(x / y)  Good Luck.-Jessy Houle  Try something like Dim x As Integer = 41 Dim y As Integer = 60 Dim result As Decimal = x / y result = Math.Floor(result)  Regards,Vinz"Code, Beer and Music&...

Web resources about - convert to integer without rounding a number -

Rounding - Wikipedia, the free encyclopedia
This article is about numerical rounding. For lip-rounding in phonetics, see Labialisation . For other uses, see Rounding (disambiguation) . ...

Decimal Rounding on the App Store on iTunes
Get Decimal Rounding on the App Store. See screenshots and ratings, and read customer reviews.

Christmas in summer: Rounding up Gadgety Goodness in NYC
Check out the newest gadgets on display in the world of consumer electronics

Christmas in summer: Rounding up Gadgety Goodness in NYC
The temperatures were hovering near 80, but there definitely was a "Christmas in June" vibe at last night's Digital Experience in New York, sponsored ...

'New Hitler' Gaddafi rounding up opponents
The son of a retired Libyan academic fears the worst for his father and three brothers after they are kidnapped by Moamar Gaddafi's forces in ...

Bell, Telus Face Lawsuit Over Rounding Up Calls To Next Full Minute
TORONTO An Ontario court has certified class action lawsuits against Telus and Bell over the practice of rounding up calls to the next full minute. Lawyers ...

Rounding Out Advertising Week With Your Burning Questions
Ad Age Publisher Allison Arden led an Advertising Week panel with four marketers at Nasdaq MarketSite today, using crowd-curated marketing questions ...

Rounding Up the Apple Rumors Ahead of WWDC
Apple will kick off its annual Worldwide Developers Conference with a Monday keynote address from CEO Tim Cook, and there’s no shortage of prognostications ...

AnandTech - AMD Radeon HD 7870 GHz Edition & Radeon HD 7850 Review: Rounding Out Southern Islands
In 2009-2010, AMD launched the entire 4 chip Evergreen series in 6 months. By previous standards this was a quick pace for a new design, especially ...

Nobody Is Rounding Up Jews In Ukraine
Donetsk Chief rabbi: leaflet distributed by separatists asking Jews to register, calls it a "provocation" #Ukraine ...

Resources last updated: 11/28/2015 12:38:26 AM