Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to add these two values using my code

VB
Me.txtPaymentMethodSubTotal.Text = ((FormatNumber(l_SubTotalWithPMFee, 2)) + (FormatNumber((txtHandlingFee.Text), 2)))


here is 0.0 IN l_SubTotalWithPMFee
and
0.00 in txtHandlingFee.Text

i want to see result 0.00 in txtPaymentMethodSubTotal.Text

but it is displaying "0.000.00"

plz help out me how can i get my desired result?
Posted
Comments
prince_rumeel 1-Oct-12 6:38am    
One exception is also with it

Conversion from string "0.000.00" to type 'Double' is not valid.

you are doing concatenation between strings, because
FormatNumber function will return string value

for proper output it should be like below,
VB
Me.txtPaymentMethodSubTotal.Text = FormatNumber(Convert.ToDouble(l_SubTotalWithPMFee) + Convert.ToDouble(txtHandlingFee.Text), 2)

Happy coding!
:)
 
Share this answer
 
There is no need for you to format the operands. Format only the result
VB
Dim PaymentSubTotal As Double = Val (l_SubTotalWithPMFee) + (txtHandlingFee.Text)
Me.txtPaymentMethodSubTotal.Text = FormatNumber(PaymentSubTotal)


Should work just fine.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900