Uma ajuda em delphi por favor!
Boa noite galera,
seguinte ..sou novo no mundo delphi .. comecei a estudar mais afundo
esse semestre na faculdade e eu preciso de uma ajuda p/ terminar um programa.
[URL=http://img4.imageshack.us/my.php?image=layoutgie.jpg][img:fe1353f4e7]http://img4.imageshack.us/img4/8973/layoutgie.th.jpg[/img:fe1353f4e7][/URL]
esse é o layout do programa
e essa é a linha de código , com as arrays e as procedures todas definidas
até onde eu consegui fazer :
Eu não sei por qual motivo o nome que eu digito não aparece no listbox.
Aparece uma definição ICE e a nota não é calculada também =/
Alguém pode dar uma ajuda?
desde já eu agradeço!
seguinte ..sou novo no mundo delphi .. comecei a estudar mais afundo
esse semestre na faculdade e eu preciso de uma ajuda p/ terminar um programa.
[URL=http://img4.imageshack.us/my.php?image=layoutgie.jpg][img:fe1353f4e7]http://img4.imageshack.us/img4/8973/layoutgie.th.jpg[/img:fe1353f4e7][/URL]
esse é o layout do programa
e essa é a linha de código , com as arrays e as procedures todas definidas
até onde eu consegui fazer :
unit Ucadaluno;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TFrmCadastro = class(TForm)
GroupBox1: TGroupBox;
BtnCadastrar: TButton;
BtnOrdenar: TButton;
BtnLimpar: TButton;
BtnSair: TButton;
Label1: TLabel;
LblReg: TLabel;
GroupBox2: TGroupBox;
BtnIncluir: TButton;
BtnConsultar: TButton;
BtnExcluir: TButton;
Label2: TLabel;
TxtMatr: TEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
TxtNome: TEdit;
TxtP1: TEdit;
TxtP2: TEdit;
GroupBox3: TGroupBox;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
LsbMatr: TListBox;
LsbNome: TListBox;
LsbMedia: TListBox;
LsbConceito: TListBox;
GpbProcura: TGroupBox;
GroupBox5: TGroupBox;
LblMsg: TLabel;
TxtProcura: TEdit;
BtnAlterar: TButton;
BtnOk: TButton;
procedure BtnSairClick(Sender: TObject);
procedure BtnLimparClick(Sender: TObject);
procedure Calcular();
procedure Registro();
procedure TxtMatrExit(Sender: TObject);
procedure TxtNomeExit(Sender: TObject);
procedure TxtP1Exit(Sender: TObject);
procedure TxtP2Exit(Sender: TObject);
procedure BtnCadastrarClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BtnIncluirClick(Sender: TObject);
procedure BtnExcluirClick(Sender: TObject);
procedure TxtProcuraExit(Sender: TObject);
{ procedure Converte();}
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmCadastro: TFrmCadastro;
VMat:Array[1..40] of String;
VNome:Array[1..40] of String;
VP1:Array[1..40] of string;
VP2:Array[1..40] of string;
VMedia:Array[1..40] of string;
VConceito:Array[1..40] of String;
i,Code:Integer;
P1text, P2text, Mediatext : String;
P1, P2, Media : real;
const limite = 3;
implementation
{$R *.dfm}
procedure TFrmCadastro.BtnSairClick(Sender: TObject);
begin
close;
end;
procedure TFrmCadastro.BtnLimparClick(Sender: TObject);
begin
txtMatr.text:=´´;
txtNome.text:=´´;
txtp1.Text := ´´;
txtp2.text :=´´;
TxtProcura.Text:=´´;
txtMatr.SetFocus;
end;
procedure TfrmCadastro.Calcular();
begin
Val (VP1[i],P1,Code);
val (VP2[i],P2,Code);
Val (VMedia[i],Media,Code);
Media:=(P1+(2*P2))/3;
if Media<4.76 then
begin
VConceito[i]:=´Reprovado´;
Str(Media:3:2,VMedia[i]);
end
else
begin
VConceito[i]:=´Aprovado´;
Str(Media:3:2,VMedia[i]);
end;
end;
procedure TFrmCadastro.FormCreate(Sender: TObject);
begin
i:=1;
LblReg.Caption:=InttoStr(i);
end;
procedure TFrmCadastro.Registro();
begin
i:=i+1;
if i>limite then
begin
BtnIncluir.Enabled:=False;
end
else
begin
TxtMatr.Text:=´´;
TxtNome.Text:=´´;
TxtP1.Text:=´´;
TxtP2.Text:=´´;
TxtMatr.SetFocus;
end;
end;
procedure TFrmCadastro.TxtMatrExit(Sender: TObject);
begin
if TxtMatr.Text=´´ then
begin
LblMsg.Caption:=´Prencha o campo matricula´;
TxtMatr.SetFocus;
end
else
begin
LblMsg.Caption:=´´;
VMat[i]:=TxtMatr.Text;
end;
end;
procedure TFrmCadastro.TxtNomeExit(Sender: TObject);
begin
if TxtNome.Text=´´ then
begin
LblMsg.Caption:=´Prencha o campo nome´;
TxtNome.SetFocus;
end
else
begin
LblMsg.Caption:=´´;
VNome[i]:=TxtNome.Text;
end;
end;
procedure TFrmCadastro.TxtP1Exit(Sender: TObject);
var
num:integer;
begin
if TxtP1.Text=´´ then
begin
LblMsg.Caption:=´Prencha o campo P1´;
TxtP1.SetFocus;
end
else
Begin
num:=StrToInt(TxtP1.Text);
if (num<0)or(num>10)then
begin
LblMsg.Caption:=´Nota fora do intervalo´;
TxtP1.SetFocus;
TxtP1.Text:=´´;
end
else
begin
LblMsg.Caption:=´´;
VP1[i]:=TxtP1.Text;
end;
end;
end;
procedure TFrmCadastro.TxtP2Exit(Sender: TObject);
var
num:integer;
begin
if TxtP2.Text=´´ then
begin
LblMsg.Caption:=´Prencha o campo P2´;
TxtP2.SetFocus;
end
else
Begin
num:=StrToInt(TxtP2.Text);
if (num<0)or(num>10)then
begin
LblMsg.Caption:=´Nota fora do intervalo´;
TxtP2.SetFocus;
TxtP2.Text:=´´;
end
else
begin
LblMsg.Caption:=´´;
VP2[i]:=TxtP2.Text;
end;
end;
end;
procedure TFrmCadastro.BtnCadastrarClick(Sender: TObject);
begin
BtnIncluir.Enabled:=true;
BtnExcluir.Enabled:=true;
BtnAlterar.Enabled:=true;
BtnConsultar.Enabled:=true;
GroupBox2.Visible:=True;
TxtMatr.SetFocus;
end;
procedure TFrmCadastro.BtnIncluirClick(Sender: TObject);
begin
Calcular;
LsbMatr.Items.Add(VMat[i]);
LsbNome.Items.Add(VNome[i]);
LsbMedia.Items.Add(VMedia[i]);
LsbConceito.Items.Add(VConceito[i]);
Registro;
LblReg.Caption:=inttostr(i);
end;
procedure TFrmCadastro.BtnExcluirClick(Sender: TObject);
begin
GpbProcura.Visible:=True;
TxtProcura.SetFocus;
TxtMatr.Text:=´´;
TxtNome.Text:=´´;
TxtP1.Text:=´´;
TxtP2.Text:=´´;
if TxtProcura.Text=VMat[i] then
begin
LblMsg.Caption:=´´;
end
else
begin
LblMsg.Caption:=´´;
LblMsg.Caption:=´Numero de matricula invalido´;
end;
end;
procedure TFrmCadastro.TxtProcuraExit(Sender: TObject);
begin
TxtProcura.TabOrder:=5;
end;
end.
Eu não sei por qual motivo o nome que eu digito não aparece no listbox.
Aparece uma definição ICE e a nota não é calculada também =/
Alguém pode dar uma ajuda?
desde já eu agradeço!
Leznx
Curtidas 0
Respostas
Marco Salles
08/05/2009
Bem ... ta complicado
As escolha ensistem em Programação Estruturada
Depois a dificuldade é maior
Fiz rapidinho aqui
Se quiser testar ,
As escolha ensistem em Programação Estruturada
Depois a dificuldade é maior
Fiz rapidinho aqui
Se quiser testar ,
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TAluno = class
private
FNome:String;
FMatricula:String;
FNota:real;
FConceito:char;
public
property Nome:String read FNome write FNome;
property Matricula:String read FMatricula write FMatricula;
property Nota:real read FNota write FNota;
property Conceito:char read FConceito write FConceito;
end;
type
TForm1 = class(TForm)
btnInserir: TButton;
btnRecuperandoOsObjetos: TButton;
BtnConsultando: TButton;
procedure FormCreate(Sender: TObject);
procedure btnInserirClick(Sender: TObject);
procedure btnRecuperandoOsObjetosClick(Sender: TObject);
procedure BtnConsultandoClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
ListaDeAlunos :TStrings;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ListaDeAlunos:=TStringList.Create;
end;
procedure TForm1.btnInserirClick(Sender: TObject);
var
umAluno:TAluno;
begin
umAluno:=TAluno.Create;
umAluno.Nome:=´´;//Vem de algum edtNome.tex ;
umAluno.Matricula:=´´;//Vem de algum edtMatricula.tex ;
umAluno.FNota:=0;//Vem de algum StrtoFloat(edtNota1.text)+StrtoFloat(edtNota1.text)+ ;
if umAluno.Nota >= 7 Then //7 = condicao qualquer
umAluno.Conceito:=´A´
else
umAluno.Conceito:=´R´;
ListaDeAlunos.AddObject(umAluno.Nome,umAluno);
end;
procedure TForm1.btnRecuperandoOsObjetosClick(Sender: TObject);
var
idx:integer;
cNome:String;
cMatricula:String;
cNota:real;
cConceito:char;
begin
for idx:=0 to ListaDeAlunos.Count - 1 do
begin
with TAluno(ListaDeAlunos.Objects[idx]) do
begin
cNome:=Nome;
cMatricula:=Matricula;
cNota:=Nota;
cConceito:=Conceito;
end;
ShowMessage(
´Matricula = ´+cMatricula+13+
´Nome = ´+cNome+13+
´Nota = ´+Floattostr(cNota)+13+
´Conceito = ´+cConceito);
end;
end;
procedure TForm1.BtnConsultandoClick(Sender: TObject);
var
idx:integer;
cNome:String;
cMatricula:String;
cNota:real;
cConceito:char;
begin
idx:=ListaDeAlunos.IndexOf(´Digitar un Nome De Aluno qq´);
if idx > -1 Then
begin
with TAluno(ListaDeAlunos.Objects[idx]) do
begin
cNome:=Nome;
cMatricula:=Matricula;
cNota:=Nota;
cConceito:=Conceito;
end;
ShowMessage(
´Matricula = ´+cMatricula+13+
´Nome = ´+cNome+13+
´Nota = ´+Floattostr(cNota)+13+
´Conceito = ´+cConceito);
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
idx:integer;
begin
for idx:=0 to ListaDeAlunos.Count - 1 do
TAluno(ListaDeAlunos.Objects[idx]).Free;
FreeandNil(ListaDeAlunos);
end;
end.GOSTEI 0
Marco Salles
08/05/2009
desculpem
é a pressa
E desse site que não permite editar ..
As escolha ensistem em Programação Estruturada
é a pressa
As escolas Insistem em Programação Estruturada
E desse site que não permite editar ..
GOSTEI 0