Solved

VB.Net Stop ineger rounding

Posted on 2011-03-02
7
410 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
ID: 35017569
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
ID: 35017576
which value did u tried and was rounded to 1?
0
 

Author Comment

by:Letsgetcoding
ID: 35017604
Private HomepageFeature As Integer = 39
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35017977
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
ID: 35018013
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
ID: 35018262
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
ID: 35018942
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Loop not working 29 46
VB.Net Serial COM1 Port - how to send this text via Serial COM port? 13 41
How to use odbc in vb to connect to ms sql 14 25
Entity Framework 7 27
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

947 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

23 Experts available now in Live!

Get 1:1 Help Now