Jump to content

adding up decimal ...

- - - - -

  • Please log in to reply
1 reply to this topic

#1
xxxxjayxxx

xxxxjayxxx

    Programmer

  • Members
  • PipPipPipPip
  • 123 posts
Posted Image
I'm having some problem here ... everytime i press the 1 , 0.5 or 0.2 they will reappear in the txtbox. What can i do to make them add all together? For example when i press 0.5 three times and 0.2 five time 2.5 will appear in the txtbox .

#2
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
you can write this statement in every button click
txtResult.Text = Convert.ToString(string.IsNullOrEmpty(txtResult.Text) ? 0.00 : Convert.ToDouble(txtResult.Text) + Convert.ToDouble(btn1.Text));
where txtResult is ID of the Textbox, btn1 is the ID of the button[ i used the button's text because they represent the numbers]




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users