Solved

VB.Net Stop ineger rounding

Posted on 2011-03-02
7
402 Views
Last Modified: 2012-05-11
Hey,

How do I stop an integer from rounding?
I have numbers set out as #.##, but it always rounds to just 1 number.

How do I stop this?

Thanks!
0
Comment
Question by:Letsgetcoding
7 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
Comment Utility
can u post the whole code?

i tried this and it didn;t round:

Dim s As String
        s = Format(0.15162342, "#.##") -->0.15

        s = Format(0.85162342, "#.##") --> 0.85
0
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
which value did u tried and was rounded to 1?
0
 

Author Comment

by:Letsgetcoding
Comment Utility
Private HomepageFeature As Integer = 39
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
You can't stop and Integer from rounding. An integer by definition is a whole (i.e. non-decimal) number. You need to change data type to a floating-point type if you want decimals.
0
 
LVL 42

Expert Comment

by:sedgwick
Comment Utility
39 is an integer type so how exactly it was rounded to 1?!?!?
i don't understand where the issue comes from, can u explain with code?
0
 
LVL 3

Expert Comment

by:MTroutwine
Comment Utility
You can take look at this article: http://vbnotebookfor.net/2007/07/31/what-you-should-know-about-rounding-in-vbnet/


However, I have to agree with the other comments.  If you are using an Integer data type you will not have any floating point value.  You will need to choose a data type that supports floating points such as Decimal, Float, Double. etc.
0
 

Author Comment

by:Letsgetcoding
Comment Utility
Have decided to go with using a string. I misunderstood what an integer was.

Sedgwick, the part of code I was referring to was = 1. I copied the =39 by mistake. Sorry for the confusion.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Free Alternative to JIRA 4 51
Paging GridView 7 32
Need to Modify a Script I found 5 75
XML & .net 5 14
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now