With C++builder really can quickly get started, as long as it will be a little C + + Foundation, can quickly write some small programs, and VCL library components are rich, much stronger than Microsoft MFC.
Write a calculator yourself to increase your interest. C + + Foundation after the free or still have to learn to walk ...
Code:
---------------------------------------------------------------------------#include <vcl.h> #pragma Hdrstop#include "CalcMain.h"//---------------------------------------------------------------------------# pragma package (smart_init) #pragma link "rzpanel" #pragma resource "*.DFM" TForm1 *form1;//declare global variable float num1;float Result; int sort; Determine what kind of operation//---------------------------------------------------------------------------__fastcall Tform1::tform1 (tcomponent* owner): Tform (owner) {form1->edit1->clear ();//Clear text box num1=0; result=0; Assign initial value sort=0;} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton1click (TObject *sender) {edit1->text = Edit1->text + speedbutton1->caption; Edit1->selstart =bytelength (Edit1->text); Set cursor position}//---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton12click (TObject *sender) {sort = 1;//variable = 1 means addition operation NUM1 = Strtofloat (Edit1->text);Assigns a value to the first variable edit1->clear ();} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton17click (tobject *sender) {switch (sort)//judgment operation {case1:result= Num1 + strtofloat (edit1->text);//COMPUTE add break ; case2:result= num1-strtofloat (Edit1->text); Calculation Subtraction break;case3:result= Num1 * strtofloat (Edit1->text); Calculate Multiply break;case4:result= num1/strtofloat (edit1->text); Calculate Division break; Default:edit1->text= "";} Edit1->text =floattostr (Result); Displays the result of the Operation Edit1->selstart =bytelength (Edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton2click (TObject *sender) {edit1->text = Edit1->text + speedbutton2->caption; Edit1->selstart =bytelength (edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton3click (TObject *sender) {edit1->text = Edit1->text + speedbutton3->caption; EdiT1->selstart =bytelength (edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton4click (TObject *sender) {edit1->text = Edit1->text + speedbutton4->caption; Edit1->selstart =bytelength (edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton5click (TObject *sender) {edit1->text = Edit1->text + speedbutton5->caption; Edit1->selstart =bytelength (edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton6click (TObject *sender) {edit1->text = Edit1->text + speedbutton6->caption; Edit1->selstart =bytelength (edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton7click (TObject *sender) {edit1->text = Edit1->text + speedbutton7->caption; Edit1->selstart =bytelength (Edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton8click (TObject *sender) {edit1->text = Edit1->text + speedbutton8->caption; Edit1->selstart =bytelength (edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton9click (TObject *sender) {edit1->text = Edit1->text + speedbutton9->caption; Edit1->selstart =bytelength (edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton10click (TObject *sender) {edit1->text = Edit1->text + speedbutton10->caption; Edit1->selstart =bytelength (edit1->text);} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton11click (TObject *sender) {edit1->text = Edit1->text + speedbutton11->caption; Edit1->selstart =bytelength (edit1->text);} //---------------------------------------------------------------------------void __fastcall Tform1::speedbutton16click (TObject *sender) {edit1->clear (); num1=0; result=0;sort=0;} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton13click (TObject *sender) {sort = 2; NUM1 = Strtofloat (Edit1->text); Edit1->clear ();} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton14click (TObject *sender) {sort = 3; NUM1 = Strtofloat (Edit1->text); Edit1->clear ();} ---------------------------------------------------------------------------void __fastcall TForm1:: Speedbutton15click (TObject *sender) {sort = 4; NUM1 = Strtofloat (Edit1->text); Edit1->clear ();} //---------------------------------------------------------------------------
Write a simple calculator