Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate 3 EZ Pay
Message
From
25/10/2008 13:28:00
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01356419
Message ID:
01357150
Views:
28
Daniel,

The line that you used:

nNewValue = ((Math.Floor(100 * (nInput / nConstant))) / 100) * nConstant

should work ... with one caveat ... maybe VB is more lenient than C#, but when I tried that with nConstant defined as you had it, as a decimal, I get an error that I can't do that division (nInput / nConstant). But, nConstant should be an integer anyway (it's 3 in this case) ... and that made the error go away, plus it worked just fine.

So, if that's the code you're actually using, I'm not sure what VB is doing differently.

~~Bonnie




>Hi Bruce,
>
>Yes, this is what I ended up using:
>
>Dim nConstant As Decimal
>Dim nInput As Double
>Dim nNewValue As Double
>
>nInput = Convert.ToDouble(txbAMSEZPay.Text)
>nConstant = 3
>
>nNewValue = ((Math.Floor(100 * (nInput / nConstant))) / 100) * nConstant
>
>
>
>All of the below are rounding up:
>
>iNumber = Convert.ToInt32(nDouble)
>iNumber = nDouble \ 1
>iNumber = nDouble
>iNumber = CType(nDouble, Integer)
>iNumber = Math.Round(nDouble, 0)
>iNumber = Math.Ceiling(nDouble, 0)
>
>Thank you,
>Daniel
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform