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 = Textbox3.Text

TextboxTotal.Text = Math.Round((num + num2 + num3, 2))


It only adds the integers but does not return the two decimal points ... ie 1458 instead of 1458.35. It appears to round the whole number up or down instaed of displaying the decimal points.

This is becoming a major pain in the ass. TIA for any help.

2/6/2008 5:37:46 AM 91979 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 34

If you want to use use decimals then you should not be using the Integer data type as that represents whole numbers.

Instead use a DECIMAL date type

dim num as Decimal = CDec(Textbox1.Text)

2/6/2008 11:28:20 AM

 As you are retrieving the values from the textbox in Integer type variable so your decimal places value might be getting lost. Please debug and check values in num,num2,num3 and if this is the case take float type variables instead of integer.

Ravi |   Share Knowledge   |   Online messengers  
2/6/2008 11:46:08 AM

jimmy q,

Worked perfectly. No more headaches. Thanks very much. I marked your help as answer.


2/7/2008 2:54:43 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...

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

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

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

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

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

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

How do I get started with AJAX.Net?
Hi All, I'm a seasoned developer but have not yet ventured into atlas et al.  I prefer books, but will take whatever I can get if it's good and will get me going. Any recommendations? Thx in advance. Jeff try here first then learn from sample and docJames Wu (MIB426).NET is only way to goMCP, MCSE, MCDBA, MCSD, MCAD I find the materials online display features and implementations but are lacking architectural depth, and am seeking more comprehensive resources. By architectural depth, I mean that I cannot watch ...

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

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 - Adding Numbers with decimal points -

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

Record number of fine defaulters losing drivers’ licences - AdelaideNow Search Search
A CRACKDOWN on fine defaulters has resulted in a record number of drivers’ licences being suspended, figures show.

Canberra Airport boss Stephen Byron sounds warning on arrival numbers amid federal budget cuts
Canberra Airport boss Stephen Byron sounds new warning on arrival numbers amid federal budget cuts.

How HuffPost, Sleep Number Will Use Each Other's Data in Branded-Content Deal
... that touched on the importance of sleep, the agency exec pitched Ms. Huffington on doing a branded-content deal with Horizon client Sleep Number. ...

Number of global refugees to hit record 60 million by end of year
Al-Bawaba Number of global refugees to hit record 60 million by end of year Al-Bawaba . Click here to add Antonio Guterres as an alert. Click ...

4 theories about why Trump's poll numbers are comparatively low in Wisconsin.
Milwaukee Journal Sentinel columnist Craig Gilbert speculates. The theories are: 1. Trump lacks the "niceness" that's the style in Wisconsin. ...

Bernie Sanders Heads into Hillary Clinton's Foreign Policy Turf: The Democratic Debate By the Numbers ...
And Martin O'Malley stole the show on gun control, Bloomberg Politics analysis shows

Star Wars: The Force Awakens Is Posting Insane Numbers, May Be The Biggest Movie Ever
You probably already knew that Star Wars: The Force Awakens is a big deal, but looking at the insane box office numbers it's already put up will ...

Chelsea Clinton Is Pregnant With Baby Number Two!
Chelsea Clinton Is Pregnant With Baby Number Two!

Resources last updated: 12/22/2015 12:00:55 AM