# Answer with out button press

**URL:** <https://forum.xojo.com/t/answer-with-out-button-press/17582>\
**Category:** General\
**Created:** [June 29, 2014, 12:41am UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582 "2014-06-29T00:41:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane\_Rampling](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@Shane\_Rampling](https://forum.xojo.com/u/Shane_Rampling)\
**Post date:** [June 29, 2014, 12:41am UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582/1 "2014-06-29T00:41:03Z")

</div>

I am using a textfield to enter data and am using a Pushbutton to calculate the result with the following code.  
dim ratio as double  
ratio = val(txtmm.text) \* 0.0393700787  
txtanswer.text = Format(ratio,“0.00000”) + " Inches"  
txtcalculation.text = “1 mm = 0.03937 inches”

Everything work fine.

What I am wondering is there a way for the answer to be calculated as the data is entered without having to click on the pushbutton.

Thanks Shane

---

<div class="post-metadata">

**Author:** ![Gavin\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gavin_smith/32/13901_2.png) [@Gavin\_Smith](https://forum.xojo.com/u/Gavin_Smith)\
**Post date:** [June 29, 2014, 12:43am UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582/2 "2014-06-29T00:43:41Z")

</div>

[quote=105635:@Shane Rampling]I am using a textfield to enter data and am using a Pushbutton to calculate the result with the following code.  
dim ratio as double  
ratio = val(txtmm.text) \* 0.0393700787  
txtanswer.text = Format(ratio,“0.00000”) + " Inches"  
txtcalculation.text = “1 mm = 0.03937 inches”

Everything work fine.

What I am wondering is there a way for the answer to be calculated as the data is entered without having to click on the pushbutton.

Thanks Shane[/quote]

Sure, use the TextChange event of the TextField. [http://documentation.xojo.com/index.php/TextField.TextChange](http://documentation.xojo.com/index.php/TextField.TextChange)

---

<div class="post-metadata">

**Author:** ![Richard\_Summers](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_summers/32/477_2.png) [@Richard\_Summers](https://forum.xojo.com/u/Richard_Summers)\
**Post date:** [June 29, 2014, 12:45am UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582/3 "2014-06-29T00:45:23Z")

</div>

TextChanged event should be what you are looking for.

---

<div class="post-metadata">

**Author:** ![Shane\_Rampling](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@Shane\_Rampling](https://forum.xojo.com/u/Shane_Rampling)\
**Post date:** [June 29, 2014, 12:55am UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582/4 "2014-06-29T00:55:55Z")

</div>

Thanks for the replies, I am only a beginer at programing and not sure how to implement some of these things, how would I go about it.

Thanks Shane.

---

<div class="post-metadata">

**Author:** ![Richard\_Summers](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_summers/32/477_2.png) [@Richard\_Summers](https://forum.xojo.com/u/Richard_Summers)\
**Post date:** [June 29, 2014, 1:00am UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582/5 "2014-06-29T01:00:32Z")

</div>

Shane,  
Single click on the name of the textfield in the navigator area (left hand side), and then click on Insert \> EventHandler from the top menubar.

Then add the TextChanged event handler.  
Then put your code in there.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![Shane\_Rampling](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@Shane\_Rampling](https://forum.xojo.com/u/Shane_Rampling)\
**Post date:** [June 29, 2014, 1:06am UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582/6 "2014-06-29T01:06:42Z")

</div>

Thanks Richard, exactly what I was after.

---

<div class="post-metadata">

**Author:** ![Richard\_Summers](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_summers/32/477_2.png) [@Richard\_Summers](https://forum.xojo.com/u/Richard_Summers)\
**Post date:** [June 29, 2014, 1:11am UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582/7 "2014-06-29T01:11:27Z")

</div>

Glad I could help you 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:17pm UTC](https://forum.xojo.com/t/answer-with-out-button-press/17582/8 "2020-10-29T17:17:51Z")

</div>


