# Setting value to active form control

**URL:** <https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588>\
**Category:** Developer Forum\
**Created:** [January 28, 2015, 6:38am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588 "2015-01-28T06:38:58Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 28, 2015, 6:38am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/1 "2015-01-28T06:38:58Z")

</div>

what is the keyword in ax 2009 to show the current pointers ???

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [January 28, 2015, 8:58am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/2 "2015-01-28T08:58:40Z")

</div>

What do you mean by “pointers”?

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 28, 2015, 9:20am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/3 "2015-01-28T09:20:37Z")

</div>

I have created this calculator , i am able to pass values from the numeric tabs from the first value “text1” but what will be the code such that i will be able to pass values in text2 as well , when i put my cursor in it ?

I have created a table

 ![2148.Dynamics.jpg](https://us1.discourse-cdn.com/flex023/uploads/dugusers/original/2X/f/fd78c81b96fbfb155ba3f7e46026b3fd73348059.jpeg)

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [January 28, 2015, 9:41am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/4 "2015-01-28T09:41:14Z")

</div>

To set value to _text2_, set its _AutoDeclaration_ property to _Yes_. Then you can use it directly in code, e.g. _text2.text(“1.00”)_. By the way, consider using _RealEdit_ instead of _StringEdit_ controls; it makes better sense for numbers.

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 28, 2015, 10:55am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/5 "2015-01-28T10:55:50Z")

</div>

i guess you didn’t understood my question right

and yes my auto declaration property is true and i am using real edit , kindly check this thread of mine .

[http://dynamicsuser.net/forums/t/81980.aspx](http://dynamicsuser.net/forums/t/81980.aspx)

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 28, 2015, 11:50am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/6 "2015-01-28T11:50:06Z")

</div>

my question is : how to switch the textbox at runtime , such that i can insert values from my numeric buttons in them while putting the cursor on any of the text box i choose at runtime ?

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [January 28, 2015, 12:07pm UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/7 "2015-01-28T12:07:01Z")

</div>

The idea is wrong from the beginning. You don’t have to (and shouldn’t) do anything with the cursor to set the value to a text box. You want to change the state of the text box object by calling its method. That’s how object-oriented programming works.

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 28, 2015, 12:28pm UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/8 "2015-01-28T12:28:40Z")

</div>

Sorry , but this is the task that has been provided by me .

My task is :

Create a Scientific Calculator , insert two text box that takes the value on which the arithmetic calculation is to be performed , There should be a third text box that displays the result of the arithmetic calculation of the corresponding text boxes . ( which i have done)

Now create number buttons and insert the values from the number buttons instead of manually typing it from keyboard (Here is where my issue starts) . I was able to insert the values in textbox1 and now i want to insert the value in textbox2 , so by putting the pointer on textbox2 when i click on the numeric buttons , instead of inserting the values in textbox2 it keep on inserting the values in textbox1 only.

**The code that i wrote for inserting value from textbox1(from button1) is :**

void clicked()

{

super();

if(text1.realValue())

{

if(text1.realValue())

{

text1.realValue(text1.realValue()\*10 + 1.0);

}

else

{

text1.realValue(1.0);

}

}

}

Do you get my query now ??

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [January 28, 2015, 1:10pm UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/9 "2015-01-28T13:10:11Z")

</div>

In that case, you need to know which textbox was activated before you started clicking on buttons. Therefore you have to save the information to a member variable and use it when a button is clicked.

For example, add _FormRealControl activeBox;_ to _classDeclaration_. Then override _gotFocus()_ of both real edit controls and add _activeBox = this;_ there. It means that _activeBox_ variable will always contain the last activated input box. And your buttons won’t care about which one is active - they’ll simply update _activeBox_ _(activeBox.realValue(…))._

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 29, 2015, 5:57am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/10 "2015-01-29T05:57:26Z")

</div>

Thank you so much , that was really helpful.

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 29, 2015, 7:01am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/11 "2015-01-29T07:01:47Z")

</div>

One last help

When i manually inserts the value in the text box , i am able to get my calculations but when i uses the numeric buttons to insert values in the text boxes , i am not able to complete my calculations .

**The code in my button click event is as follows:**

**void clicked()**

**{**

**super();**

**if(activebox.realValue())**

**{**

**activebox.realValue(activebox.realValue()\*10 + 1.0);**

**}**

**else**

**{**

**activebox.realValue(1.0);**

**}**

**}**

**what method should i use so that i am able to perform my calculations from the numeric buttons as well ?**

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [January 29, 2015, 7:40am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/12 "2015-01-29T07:40:23Z")

</div>

Sorry, but you’re again very vague. What _“i am not able to complete my calculations”_ means? You have to realize that we don’t have any information about your problem except what you tell us.

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 29, 2015, 8:04am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/13 "2015-01-29T08:04:59Z")

</div>

Thanks a lot , my proect is now working fine and it has less codes because of you . I have solved the last query by myself and i will try to be more describable next time . Thanks a ton for your help . I am very thankful.

Regards

Shubham

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 29, 2015, 12:47pm UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/14 "2015-01-29T12:47:53Z")

</div>

**Issue1 :**

I am not able to pass value into the textbox from button at first but later on i am able to insert values from numeric buttons into the textbox . But now i am not able to insert value manually from my keyboard. My instructor told me that there is no way that we can insert the values by both keyboard and numeric button of my calculator ??

Is there any way through which i can use both for inserting values.

**Issue2:**

I added a decimal button . How can i set decimal in the input value .

**The following is the code being used by me :**

**void clicked()**

**{**

**super();**

**activebox.realValue(activebox.realValue()\*0.0);**

**}**

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [January 29, 2015, 3:13pm UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/15 "2015-01-29T15:13:51Z")

</div>

1. Sorry, I don’t know what “i am not able to insert value” mean.

2. “How can i set decimal in the input value” - What’s the problem?

You’ll have to do better job with formulating your questions to get any answers.

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 30, 2015, 6:13am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/16 "2015-01-30T06:13:29Z")

</div>

How can i insert decimal value from my decimal button

what will be the appropriate code ?

I have used this code in the click method as :

**void clicked()**

**{**

**super();**

**activebox.realValue(activebox.realValue()\*0.0);**

**}**

---

<div class="post-metadata">

**Author:** ![Shubham\_Sharma](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Shubham\_Sharma](https://www.dynamicsuser.net/u/Shubham_Sharma)\
**Post date:** [January 30, 2015, 6:15am UTC](https://www.dynamicsuser.net/t/setting-value-to-active-form-control/56588/17 "2015-01-30T06:15:20Z")

</div>

As a newbie , i am trying really hard to understand the stuff and to make it more understandable to you . You have had really helped me a lot in clearing my doubts . Sorry for using such a vague language , i ll keep in mind to be as simple as i can .

Thanks a lot
