Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate 3 EZ Pay
Message
De
25/10/2008 13:28:00
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01356419
Message ID:
01357150
Vues:
27
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform