Setting value to active form control

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

What do you mean by “pointers”?

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

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.

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

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 ?

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.

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 ??

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(…)).

Thank you so much , that was really helpful.

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 ?

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.

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

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);

}

  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.

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);

}

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