Create simple calculator with Dynamic AX 2012
I'm new with Dynamic AX and I want to create a simple calculator with input values and display the result in the form:

axapta x++
add a comment |
I'm new with Dynamic AX and I want to create a simple calculator with input values and display the result in the form:

axapta x++
2
To learn more about forms take a look on forms named "Tutorial_" fx.Tutorial_Form_Controls. You need to expand your question with what you have tried and what did not work.
– Jan B. Kjeldsen
Nov 13 '18 at 8:53
add a comment |
I'm new with Dynamic AX and I want to create a simple calculator with input values and display the result in the form:

axapta x++
I'm new with Dynamic AX and I want to create a simple calculator with input values and display the result in the form:

axapta x++
axapta x++
edited Nov 13 '18 at 11:03
Alex
1,203314
1,203314
asked Nov 13 '18 at 8:24
satriosatrio
11
11
2
To learn more about forms take a look on forms named "Tutorial_" fx.Tutorial_Form_Controls. You need to expand your question with what you have tried and what did not work.
– Jan B. Kjeldsen
Nov 13 '18 at 8:53
add a comment |
2
To learn more about forms take a look on forms named "Tutorial_" fx.Tutorial_Form_Controls. You need to expand your question with what you have tried and what did not work.
– Jan B. Kjeldsen
Nov 13 '18 at 8:53
2
2
To learn more about forms take a look on forms named "Tutorial_" fx.
Tutorial_Form_Controls. You need to expand your question with what you have tried and what did not work.– Jan B. Kjeldsen
Nov 13 '18 at 8:53
To learn more about forms take a look on forms named "Tutorial_" fx.
Tutorial_Form_Controls. You need to expand your question with what you have tried and what did not work.– Jan B. Kjeldsen
Nov 13 '18 at 8:53
add a comment |
1 Answer
1
active
oldest
votes
Your question is very broad to be answered precisely because there are a lot of strategies to tackle the task, but judging from the screenshot you have provided you have a class which should contain all calculation logic and a form to provide UI to the user with two input fields and one output field which should display operation result.
So the easiest solution would be:
- Implement the
Kalkulatorclass which exposes twoparmmethods to
set up the operands and four methods which execute the
operation and return the result:add,subtract,multiplyanddivide. - Create a private instance of the
Kalkulatorclass in your form,
initialize it, set up operands when user clicks one of the buttons,
call appropriate method to run the operation and output the result
on the form field.
So supposing that operands are integer values (for demonstrative purpose) your TRN_Kalkulator may look something like this:
class TRN_Kalkulator
{
private int value1;
private int value2;
public int parmValue1(int _value = value1)
{
value1 = _value;
return value1;
}
public int parmValue2(int _value = value2)
{
value2 = _value;
return value2;
}
public int Sum()
{
return value1 + value2;
}
public int Diff()
{
return value1 - value2;
}
public int Mult()
{
return value1 * value2;
}
public int Div()
{
return value2 == 0 ? 0 : value1 / value2;
}
}
In the class declaration on the form you have to declare a private instance of TRN_Kalkulator which will be initialized by overriding the init() method:
TRN_Kalkulator calculator;
//...
public void init()
{
super();
calculator = new TRN_Kalkulator();
}
Finally when one of the buttons is clicked you parse user input by reading the values of the form fields, set up the operands, run the operation and output the result. All of this is done by overriding click() method on each of the buttons:
// read text values of the textboxes and parse them to integer
int a = str2Int(TxtOperand1.text());
int b = str2Int(TxtOperand2.text());
// set up calculator operands
calculator.parmValue1(a);
calculator.parmValue2(b);
// call the operation depending on which button was clicked
int result = calculator.Sum();
// set result textbox text
TxtResult.text(int2Str(result));
Notice that there are a lot of ways to improve this code (like for example using some display and edit methods on the form) and you definitely should do it, but this implementation suits your current setup and should point you in the right direction.
thank u so much, actualy i have create first point but i can execute that, your answer is very helpfull
– satrio
Nov 13 '18 at 9:34
Of cause, if your two controls areFormRealControlyou can use theoperand1.realValue()to get the values directly.
– Jan B. Kjeldsen
Nov 14 '18 at 15:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276700%2fcreate-simple-calculator-with-dynamic-ax-2012%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your question is very broad to be answered precisely because there are a lot of strategies to tackle the task, but judging from the screenshot you have provided you have a class which should contain all calculation logic and a form to provide UI to the user with two input fields and one output field which should display operation result.
So the easiest solution would be:
- Implement the
Kalkulatorclass which exposes twoparmmethods to
set up the operands and four methods which execute the
operation and return the result:add,subtract,multiplyanddivide. - Create a private instance of the
Kalkulatorclass in your form,
initialize it, set up operands when user clicks one of the buttons,
call appropriate method to run the operation and output the result
on the form field.
So supposing that operands are integer values (for demonstrative purpose) your TRN_Kalkulator may look something like this:
class TRN_Kalkulator
{
private int value1;
private int value2;
public int parmValue1(int _value = value1)
{
value1 = _value;
return value1;
}
public int parmValue2(int _value = value2)
{
value2 = _value;
return value2;
}
public int Sum()
{
return value1 + value2;
}
public int Diff()
{
return value1 - value2;
}
public int Mult()
{
return value1 * value2;
}
public int Div()
{
return value2 == 0 ? 0 : value1 / value2;
}
}
In the class declaration on the form you have to declare a private instance of TRN_Kalkulator which will be initialized by overriding the init() method:
TRN_Kalkulator calculator;
//...
public void init()
{
super();
calculator = new TRN_Kalkulator();
}
Finally when one of the buttons is clicked you parse user input by reading the values of the form fields, set up the operands, run the operation and output the result. All of this is done by overriding click() method on each of the buttons:
// read text values of the textboxes and parse them to integer
int a = str2Int(TxtOperand1.text());
int b = str2Int(TxtOperand2.text());
// set up calculator operands
calculator.parmValue1(a);
calculator.parmValue2(b);
// call the operation depending on which button was clicked
int result = calculator.Sum();
// set result textbox text
TxtResult.text(int2Str(result));
Notice that there are a lot of ways to improve this code (like for example using some display and edit methods on the form) and you definitely should do it, but this implementation suits your current setup and should point you in the right direction.
thank u so much, actualy i have create first point but i can execute that, your answer is very helpfull
– satrio
Nov 13 '18 at 9:34
Of cause, if your two controls areFormRealControlyou can use theoperand1.realValue()to get the values directly.
– Jan B. Kjeldsen
Nov 14 '18 at 15:06
add a comment |
Your question is very broad to be answered precisely because there are a lot of strategies to tackle the task, but judging from the screenshot you have provided you have a class which should contain all calculation logic and a form to provide UI to the user with two input fields and one output field which should display operation result.
So the easiest solution would be:
- Implement the
Kalkulatorclass which exposes twoparmmethods to
set up the operands and four methods which execute the
operation and return the result:add,subtract,multiplyanddivide. - Create a private instance of the
Kalkulatorclass in your form,
initialize it, set up operands when user clicks one of the buttons,
call appropriate method to run the operation and output the result
on the form field.
So supposing that operands are integer values (for demonstrative purpose) your TRN_Kalkulator may look something like this:
class TRN_Kalkulator
{
private int value1;
private int value2;
public int parmValue1(int _value = value1)
{
value1 = _value;
return value1;
}
public int parmValue2(int _value = value2)
{
value2 = _value;
return value2;
}
public int Sum()
{
return value1 + value2;
}
public int Diff()
{
return value1 - value2;
}
public int Mult()
{
return value1 * value2;
}
public int Div()
{
return value2 == 0 ? 0 : value1 / value2;
}
}
In the class declaration on the form you have to declare a private instance of TRN_Kalkulator which will be initialized by overriding the init() method:
TRN_Kalkulator calculator;
//...
public void init()
{
super();
calculator = new TRN_Kalkulator();
}
Finally when one of the buttons is clicked you parse user input by reading the values of the form fields, set up the operands, run the operation and output the result. All of this is done by overriding click() method on each of the buttons:
// read text values of the textboxes and parse them to integer
int a = str2Int(TxtOperand1.text());
int b = str2Int(TxtOperand2.text());
// set up calculator operands
calculator.parmValue1(a);
calculator.parmValue2(b);
// call the operation depending on which button was clicked
int result = calculator.Sum();
// set result textbox text
TxtResult.text(int2Str(result));
Notice that there are a lot of ways to improve this code (like for example using some display and edit methods on the form) and you definitely should do it, but this implementation suits your current setup and should point you in the right direction.
thank u so much, actualy i have create first point but i can execute that, your answer is very helpfull
– satrio
Nov 13 '18 at 9:34
Of cause, if your two controls areFormRealControlyou can use theoperand1.realValue()to get the values directly.
– Jan B. Kjeldsen
Nov 14 '18 at 15:06
add a comment |
Your question is very broad to be answered precisely because there are a lot of strategies to tackle the task, but judging from the screenshot you have provided you have a class which should contain all calculation logic and a form to provide UI to the user with two input fields and one output field which should display operation result.
So the easiest solution would be:
- Implement the
Kalkulatorclass which exposes twoparmmethods to
set up the operands and four methods which execute the
operation and return the result:add,subtract,multiplyanddivide. - Create a private instance of the
Kalkulatorclass in your form,
initialize it, set up operands when user clicks one of the buttons,
call appropriate method to run the operation and output the result
on the form field.
So supposing that operands are integer values (for demonstrative purpose) your TRN_Kalkulator may look something like this:
class TRN_Kalkulator
{
private int value1;
private int value2;
public int parmValue1(int _value = value1)
{
value1 = _value;
return value1;
}
public int parmValue2(int _value = value2)
{
value2 = _value;
return value2;
}
public int Sum()
{
return value1 + value2;
}
public int Diff()
{
return value1 - value2;
}
public int Mult()
{
return value1 * value2;
}
public int Div()
{
return value2 == 0 ? 0 : value1 / value2;
}
}
In the class declaration on the form you have to declare a private instance of TRN_Kalkulator which will be initialized by overriding the init() method:
TRN_Kalkulator calculator;
//...
public void init()
{
super();
calculator = new TRN_Kalkulator();
}
Finally when one of the buttons is clicked you parse user input by reading the values of the form fields, set up the operands, run the operation and output the result. All of this is done by overriding click() method on each of the buttons:
// read text values of the textboxes and parse them to integer
int a = str2Int(TxtOperand1.text());
int b = str2Int(TxtOperand2.text());
// set up calculator operands
calculator.parmValue1(a);
calculator.parmValue2(b);
// call the operation depending on which button was clicked
int result = calculator.Sum();
// set result textbox text
TxtResult.text(int2Str(result));
Notice that there are a lot of ways to improve this code (like for example using some display and edit methods on the form) and you definitely should do it, but this implementation suits your current setup and should point you in the right direction.
Your question is very broad to be answered precisely because there are a lot of strategies to tackle the task, but judging from the screenshot you have provided you have a class which should contain all calculation logic and a form to provide UI to the user with two input fields and one output field which should display operation result.
So the easiest solution would be:
- Implement the
Kalkulatorclass which exposes twoparmmethods to
set up the operands and four methods which execute the
operation and return the result:add,subtract,multiplyanddivide. - Create a private instance of the
Kalkulatorclass in your form,
initialize it, set up operands when user clicks one of the buttons,
call appropriate method to run the operation and output the result
on the form field.
So supposing that operands are integer values (for demonstrative purpose) your TRN_Kalkulator may look something like this:
class TRN_Kalkulator
{
private int value1;
private int value2;
public int parmValue1(int _value = value1)
{
value1 = _value;
return value1;
}
public int parmValue2(int _value = value2)
{
value2 = _value;
return value2;
}
public int Sum()
{
return value1 + value2;
}
public int Diff()
{
return value1 - value2;
}
public int Mult()
{
return value1 * value2;
}
public int Div()
{
return value2 == 0 ? 0 : value1 / value2;
}
}
In the class declaration on the form you have to declare a private instance of TRN_Kalkulator which will be initialized by overriding the init() method:
TRN_Kalkulator calculator;
//...
public void init()
{
super();
calculator = new TRN_Kalkulator();
}
Finally when one of the buttons is clicked you parse user input by reading the values of the form fields, set up the operands, run the operation and output the result. All of this is done by overriding click() method on each of the buttons:
// read text values of the textboxes and parse them to integer
int a = str2Int(TxtOperand1.text());
int b = str2Int(TxtOperand2.text());
// set up calculator operands
calculator.parmValue1(a);
calculator.parmValue2(b);
// call the operation depending on which button was clicked
int result = calculator.Sum();
// set result textbox text
TxtResult.text(int2Str(result));
Notice that there are a lot of ways to improve this code (like for example using some display and edit methods on the form) and you definitely should do it, but this implementation suits your current setup and should point you in the right direction.
edited Nov 13 '18 at 9:24
answered Nov 13 '18 at 9:19
AlexAlex
1,203314
1,203314
thank u so much, actualy i have create first point but i can execute that, your answer is very helpfull
– satrio
Nov 13 '18 at 9:34
Of cause, if your two controls areFormRealControlyou can use theoperand1.realValue()to get the values directly.
– Jan B. Kjeldsen
Nov 14 '18 at 15:06
add a comment |
thank u so much, actualy i have create first point but i can execute that, your answer is very helpfull
– satrio
Nov 13 '18 at 9:34
Of cause, if your two controls areFormRealControlyou can use theoperand1.realValue()to get the values directly.
– Jan B. Kjeldsen
Nov 14 '18 at 15:06
thank u so much, actualy i have create first point but i can execute that, your answer is very helpfull
– satrio
Nov 13 '18 at 9:34
thank u so much, actualy i have create first point but i can execute that, your answer is very helpfull
– satrio
Nov 13 '18 at 9:34
Of cause, if your two controls are
FormRealControl you can use the operand1.realValue() to get the values directly.– Jan B. Kjeldsen
Nov 14 '18 at 15:06
Of cause, if your two controls are
FormRealControl you can use the operand1.realValue() to get the values directly.– Jan B. Kjeldsen
Nov 14 '18 at 15:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53276700%2fcreate-simple-calculator-with-dynamic-ax-2012%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
To learn more about forms take a look on forms named "Tutorial_" fx.
Tutorial_Form_Controls. You need to expand your question with what you have tried and what did not work.– Jan B. Kjeldsen
Nov 13 '18 at 8:53