Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
Guest C++ kana

Tratamento de exceção

Question

Guest C++ kana

:P :lol: Olá galera....

Estou com uma duvida, caso alguém possa me ajudar ....

Fiz uma programa em aula em que tinhamos que usar um tratamento de exceção.

Porém ao rodar o meu códio no Builder 6, a mensagem de erro quando ocorre a exceção, não funcionou corretamente.

Me falaram que eu devia fazer o encapsulamento do tratamento de excesão em cad objeto que o utiliza.....Qual a melhor maneira de fazer isto????

Caso alguém puder me ajudar...segue abaixo o código.... :blush:

include <vcl.h>
#pragma hdrstop

#include "cambio.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString FORMATO;
float troca;
troca=StrToFloat(Edit1->Text);

 try{
if(RadioButton5->Checked)
        {

        troca=troca/2.5;
        FORMATO=FormatFloat("E$#,##0.00;-E$#,#0.00",troca);
        Edit2->Color=clRed;
        Edit2->Text=FORMATO;


        }
if(RadioButton6->Checked)
        {
        troca=troca/1.8;
        FORMATO=FormatFloat("U$#,##0.00;-U$#,#0.00",troca);
        Edit2->Color=clGreen;
        Edit2->Text=FORMATO;
        }
if(RadioButton1->Checked)
        {
         troca=troca/1.5;
        FORMATO=FormatFloat("Rublos$#,##0.00;-Rublos$#,#0.00",troca);
        Edit2->Color=clBlue;
        Edit2->Text=FORMATO;
        }
     }
      catch(EConvertError&)
           {ShowMessage("AJAJHAHJ");}
}
//---------------------------------------------------------------------------



void __fastcall TForm1::RadioButton2Click(TObject *Sender)
{

Form1->Color=clBlue;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioButton3Click(TObject *Sender)
{
Form1->Color=clWhite;         
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioButton4Click(TObject *Sender)
{
Form1->Color=clGreen;         
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioButton7Click(TObject *Sender)
{
Form1->Color=clBtnFace;         
}
//---------------------------------------------------------------------------

void __fastcall TForm1::enter(TObject *Sender)
{
  if(dynamic_cast<TEdit*>(Sender)!=NULL)
        {
                ((TEdit*)Sender)->Color=clYellow;
        }        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Edit1Exit(TObject *Sender)
{
 if(dynamic_cast<TEdit*>(Sender)!=NULL)
        {
                ((TEdit*)Sender)->Color=clWhite;
        }
}
//---------------------------------------------------------------------------




void __fastcall TForm1::Button2Click(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
Application->Terminate();

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

Cloud Computing


  • Forum Statistics

    • Total Topics
      148582
    • Total Posts
      644298
×
×
  • Create New...