Witam
Mam taki problem.
Dostaliśmy na zadanie domowe dokończyć program w c++ telefon.
Zasada działania podobna jak w pisaniu sms-a. po kliknięciu np. 5 pojawia się po kolei
j,k,l,5 i my mamy coś takiego zrobić. Próbowałem to rozgryźć lecz pojawiają mi się dwa znaki naraz.

Proszę o jakieś sugestie.

Przesyłam kod:

 void __fastcall TMDIChild::FormClose(TObject *Sender, TCloseAction &Action)
{
	Action = caFree;
}
//---------------------------------------------------------------------
void __fastcall TMDIChild::DodajLitereExecute(TObject *Sender)
{
        TButton *b = (TButton*)Sender;
        int leng = b->Caption.Length();
        String text = b->Caption;
        String c;
        String text2;
        for(int i=1;i<=leng;i++){
                if(text[i]=='&'){
                        if(i==leng){
                                text2 = text.SubString(1,leng-1);
                                text = "&"+ text2;
                        }
                        swap(text[i],text[i+1]);
                        if(i>1){
                                c = text.SubString(i-1,i);
                        }else{
                                c = text[i];
                        }
                        break;
                }else{
                        c = c + text[i+1];
                }
        }
        b->Caption = text;
        Memo1->Text = c;
 
}
//---------------------------------------------------------------------------
 
 
_fastcall TMainForm::TMainForm(TComponent *Owner)
	: TForm(Owner)
{
        srand(time(NULL));
}
//---------------------------------------------------------------------------
 
void __fastcall TMainForm::CreateMDIChild(String Name)
{
	TMDIChild *Child;
 
	//--- create a new MDI child window ----
	Child = new TMDIChild(Application);
	Child->Caption = Name;
	if (FileExists (Name))
		Child->Memo1->Lines->LoadFromFile(Name);
}
//---------------------------------------------------------------------------
 
void __fastcall TMainForm::FileNew1Execute(TObject *Sender)
{
	CreateMDIChild(Losuj());
 
}
//---------------------------------------------------------------------------
 
void __fastcall TMainForm::FileOpen1Execute(TObject *Sender)
{
	if (OpenDialog->Execute())
		CreateMDIChild(OpenDialog->FileName);
}
//---------------------------------------------------------------------------
 
void __fastcall TMainForm::HelpAbout1Execute(TObject *Sender)
{
	AboutBox->ShowModal();
}
//---------------------------------------------------------------------------
 
void __fastcall TMainForm::FileExit1Execute(TObject *Sender)
{
	Close();
}
//---------------------------------------------------------------------------