AndyK
October 4th, 1999, 11:10 PM
When I use CInt(Text1) + CInt(Text2) in a formula, it rounds the answer..i need my answer without rounding......
Thank You
Thank You
|
Click to See Complete Forum and Search --> : CInt rounds the number, but i need to display without rounding AndyK October 4th, 1999, 11:10 PM When I use CInt(Text1) + CInt(Text2) in a formula, it rounds the answer..i need my answer without rounding...... Thank You Chris Eastwood October 5th, 1999, 02:35 AM How about Dim dblX as Double Dim dblY as Double If IsNumeric(Text1.Text) then dblX = CDbl(Text1.Text) else MsgBox "Text1.Text Not Numeric" Exit sub/function/whatever End if If IsNumeric(Text2.Text) then dblY = CDbl(Text2.Text) else MsgBox "Text2.Text Not Numeric" Exit sub/function/whatever End if MsgBox "Result = " & (dblX + dblY) Chris Eastwood CodeGuru - the website for developers http://codeguru.developer.com/vb al_paso October 5th, 1999, 01:36 PM First of all what do you want to do exactly? Add just the integer part? For e.g if text1 = 3.6 and text2= 4.2 then Cint(text1) + Cint(text2) will give you 8 (4 + 4) If you just want the integer part to be added i.e 3 + 4 to give 7 then use Fix() suntosh October 6th, 1999, 01:13 AM why don't you try and use the simple Val function for eg., Text1.Text = "4.85" Text2.Text = "7.63" msgbox val(text1.text) + val(text2.text) should give you 12.48 Chris Eastwood October 6th, 1999, 02:22 AM 'Val' is notoriously bad at converting values that aren't numbers into a number equivilent - there was an article in the MSDN a long time ago about the possible errors in using the function. For instance, Val("123 Some Road") Using the IsNumeric version will work regardless of what's typed in. Chris Eastwood CodeGuru - the website for developers http://codeguru.developer.com/vb codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |