I read on this answer that Windows Calc do not use a Label not a Text Box to show the inputed numbers. As I’m new on programming I would like to know how can I use a Label to work like Windows Calc’s Label on the calc I’m developing.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Put the
Labelcontrol on the form and then put buttons for the numbers and, the operators. When a number is pressed, simply update theLabel‘sTextproperty by appending the number at the end. (The initial value of the label should be0.) When an operator is pressed, perform the operation on the value (take the label’sTextproperty and convert it to a number using theConvertclass). If the operation needs two numbers, you may have to store the first number and clear the label for a new number entry. Once you have two input numbers, just perform the operation on them and show the result.If you also want to display the operation (similar to how Calculator does it), put another label on top of the first one and just use its
Textproperty to show/clear the operation as needed.If you want to be able to press number keys on the keyboard, add keyboard event handlers (
KeyPressevent) to the form that hosts the label and then update the label as needed when a numeric or operator key is pressed. Make sure to set theKeyPreviewproperty totrueso that your form will receive all keyboard input first – this way you can direct number keys to your label.