Dúvida rápida. Lazarus. Media duas notas.
Boa tarde, sou iniciante e estou tentando criar um programa pra calcular a média de duas notas e não estou conseguindo.
Segue o código:
Eis o erro:
unit1.pas(47,33) Error: Incompatible type for arg no. 1: Got "LongInt", expected "AnsiString"
Se alguém puder ajudar agradeço imensamente.
Abraço.
Segue o código:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Windows, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
procedure Edit3Change(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
Var
Nota1, Nota2, Media: Integer;
begin
Nota1 := StrToInt (Edit1.Text);
Nota2 := StrToInt (Edit2.Text);
Media := StrToInt (Nota1+Nota2) div 2;
Edit3.Text := IntToStr(Media);
end;
end.
Eis o erro:
unit1.pas(47,33) Error: Incompatible type for arg no. 1: Got "LongInt", expected "AnsiString"
Se alguém puder ajudar agradeço imensamente.
Abraço.
Adriano Freitas
Curtidas 0
Respostas
Natanael Ferreira
28/06/2017
Não uso Lazarus, mas veja se o código abaixo funciona:
procedure TForm1.Button1Click(Sender: TObject); Var Nota1, Nota2: Integer; Media: Float; begin Nota1 := StrToInt (Edit1.Text); Nota2 := StrToInt (Edit2.Text); Media := (Nota1+Nota2) / 2; Edit3.Text := FloatToStr(Media); end;
GOSTEI 0