Search 0)? document.getElementById ('lblsearch'). style.display = 'none': document.getElementById ('lblsearch'). style.display = 'block'; "onfocus =" document.getElementById ('lblsearch'). style.display = 'none'; "/>
All contents DevMedia Technologies Front-end Java web. NET Database Mobile PHP Software rational cpc 101 Engineering Infrastructure Delphi Journals All journals Java Magazine. Easy net Java Magazine Magazine easy. Magazine SQL net Magazine Mobile Magazine Software Engineering Infrastructure Magazine ClubeDelphi Courses All courses online courses web front end Courses Java Courses. Courses net Database Engineering Courses Software Courses PHP Courses Mobile Infrastructure Courses Courses Courses Delphi automation / Invoice / Paf- ecf formations Pocket full videos DevWare Frum Serbs System Crditos DevMedia Player Ranking Register Login RSS What is there new Customer FAQ Delivery FAQ magazines Vdeo lessons Managing what was read Post Buy Signature MVP Crditos Sign Shop Buy magazines
See this article how to create a calculator bsica in Delphi, using only native components ecdigo of easy understanding, facilitating the learning of those who are starting their studies this technology.
Be used TEdit component, which is the standard palette and the palette Additional TSpeedButton component. Rather than using TSpeedButton, TButton may be used as the properties that will be used here are common to both.
Let's start a new project in Delphi. Be necessary for this calculator only one form. Where they will be added the following rational cpc 101 components: 1 TEdit and 18 TSpeedButton. Let organiz them as follows, see below.
Now that the form has already been organized with TEdit components and TSpeedButton, let's change the Caption and Name properties of TSpeedButton in the Object Inspector. Here's how it should rational cpc 101 be. Component Name Caption TSpeedButton1 A TSpeedButton2 1 Two 2 Three 3 TSpeedButton3 TSpeedButton4 TSpeedButton5 Four 4 Five 5 Six 6 TSpeedButton6 TSpeedButton7 TSpeedButton8 Seven 7 Eight 8 Nine 9 TSpeedButton9 TSpeedButton10 Zero 0 TSpeedButton11 TSpeedButton12 Less + More - TSpeedButton13 Divide / Multiply TSpeedButton14 * TSpeedButton15 MoreLess + - TSpeedButton16 Comma, TSpeedButton17 Equal = TSpeedButton18 Llimpar C
Now that j changed TSpeedButton appropriate properties, we set the following properties in the Object Inspector TEdit: Name, Text and leave the Enabled property to False TEdit. Text Display Component rational cpc 101 Name TEdit1 Leave empty
Observation: Just do it in the onclick event of a single button. Then select all the other boats and numricos in Objetct Inspector, Events tab, select omtodo created for the onclick event of the boats selected.
Listing 7: Event OnClick of the button rational cpc 101 More or Less
TForm1.igualClick procedure rational cpc 101 (Sender: TObject); var sum: real; begin value2: = StrToFloat (visor.Text); case (function) of 1: begin sum: = value1 + value2; visor.text: FloatToStr = (sum) , end, 2: begin sum: = value1-value2 visor.text: FloatToStr = (sum); end; 3: begin sum: = value1 * value2 visor.text: FloatToStr = (sum); end; 4: begin if (value2 <> 0) then begin sum: = valor1/valor2; rational cpc 101 visor.text: FloatToStr = (sum); end else begin ShowMessage ('Division by zero!'); visor.Text: = 'ERROR' , end end end / / ends the case end;
J are with all numricos rational cpc 101 boats and other boats configured, we now just aterar some properties of the form. To do this click on the form and in the Object Inspector accessory OnShow the event and add these two lines of code.
Now to finalize the changes in the form, add the following code in the OnKeyDown event. This we now enter code serves for them to be used the numbers on the keyboard to invs have to keep clicking the mouse on each button on the calculator.
TForm1.FormKeyDown rational cpc 101 procedure (Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_NUMPAD1 rational cpc 101 um.Click then, if Key = VK_NUMPAD2 dois.click then, if Key = VK_NUMPAD3 tres.click then, if Key = VK_NUMPAD4 quatro.click rational cpc 101 then, if Key = VK_NUMPAD5 cinco.click rational cpc 101 then, if Key = VK_NUMPAD6 rational cpc 101 seis.click then, if Key = VK_NUMPAD7 sete.click then, if Key = VK_NUMPAD8 oito.click then, if Key = VK_NUMPAD9 then nove.click , if Key = VK_NUMPAD0 zero.click then, if Key = VK_ADD mais.click then, if Key = VK_SUBTRACT menos.click then, if Key = VK_MULTIPLY multiplicar.click then, if Key = VK_DIVIDE dividir.click then, if Key = VK_RETURN igual.click then, if Key = VK_DECIMAL virgula.Click then, if Key = VK_DELETE then c.click; end;
so an addendum, the event is using the comma code subtraction. [H +1 ms] - Reply
[Close] This post is closed. Learn more about the signature MVP!
Video lesson
No comments:
Post a Comment