Create simple calculator with Dynamic AX 2012












0















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



enter image description here










share|improve this question




















  • 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


















0















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



enter image description here










share|improve this question




















  • 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
















0












0








0








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



enter image description here










share|improve this question
















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



enter image description here







axapta x++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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














1 Answer
1






active

oldest

votes


















1














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:




  1. Implement the Kalkulator class which exposes two parm methods to
    set up the operands and four methods which execute the
    operation and return the result: add, subtract, multiply and divide.

  2. Create a private instance of the Kalkulator class 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.






share|improve this answer


























  • 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











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


}
});














draft saved

draft discarded


















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









1














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:




  1. Implement the Kalkulator class which exposes two parm methods to
    set up the operands and four methods which execute the
    operation and return the result: add, subtract, multiply and divide.

  2. Create a private instance of the Kalkulator class 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.






share|improve this answer


























  • 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
















1














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:




  1. Implement the Kalkulator class which exposes two parm methods to
    set up the operands and four methods which execute the
    operation and return the result: add, subtract, multiply and divide.

  2. Create a private instance of the Kalkulator class 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.






share|improve this answer


























  • 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














1












1








1







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:




  1. Implement the Kalkulator class which exposes two parm methods to
    set up the operands and four methods which execute the
    operation and return the result: add, subtract, multiply and divide.

  2. Create a private instance of the Kalkulator class 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.






share|improve this answer















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:




  1. Implement the Kalkulator class which exposes two parm methods to
    set up the operands and four methods which execute the
    operation and return the result: add, subtract, multiply and divide.

  2. Create a private instance of the Kalkulator class 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.







share|improve this answer














share|improve this answer



share|improve this answer








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 are FormRealControl you can use the operand1.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











  • 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

















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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings