Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/11/2012, 09:26
Avatar de ARICARRARO
ARICARRARO
 
Fecha de Ingreso: diciembre-2010
Ubicación: México
Mensajes: 227
Antigüedad: 13 años, 4 meses
Puntos: 10
Respuesta: ¿Cómo incrementar un valor en Lazarus Pascal?

Ya lo resolví dejo el código:

Código pascal:
Ver original
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   Elementos=record
  13.     aciertos:integer;
  14.     fallos:integer;
  15.     intentos:integer;
  16.     end;
  17.  
  18.   { TForm1 }
  19.  
  20.   TForm1 = class(TForm)
  21.     Button1: TButton;
  22.     Button2: TButton;
  23.     Edit1: TEdit;
  24.     Edit2: TEdit;
  25.     Edit3: TEdit;
  26.     Edit4: TEdit;
  27.     Edit5: TEdit;
  28.     Edit6: TEdit;
  29.     Label1: TLabel;
  30.     Label2: TLabel;
  31.     Label3: TLabel;
  32.     Label4: TLabel;
  33.     Label5: TLabel;
  34.     Label6: TLabel;
  35.     procedure Button1Click(Sender: TObject);
  36.     procedure Button2Click(Sender: TObject);
  37.     procedure FormCreate(Sender: TObject);
  38.   private
  39.     { private declarations }
  40.   public
  41.     { public declarations }
  42.   end;
  43.  
  44. var
  45.   Form1: TForm1;
  46.   elemento:Elementos;
  47.  
  48. implementation
  49.  
  50. {$R *.lfm}
  51.  
  52. { TForm1 }
  53.  
  54. procedure TForm1.FormCreate(Sender: TObject);
  55.  
  56. begin
  57.  
  58. elemento.aciertos:=0;
  59. elemento.fallos:=0;
  60. elemento.intentos:=0;
  61.  
  62. end;
  63.  
  64. procedure TForm1.Button1Click(Sender: TObject);
  65. var
  66.   alea1,alea2:integer;
  67. begin
  68.     randomize;
  69.     alea1:=random(102)-25;
  70.     alea2:=random(102)-22;
  71.     Edit1.Text:=inttostr(alea1);
  72.     Edit2.Text:=inttostr(alea2);
  73.  
  74.  
  75. end;
  76.  
  77. procedure TForm1.Button2Click(Sender: TObject);
  78. var
  79.   numero,suma:integer;
  80.  
  81. begin
  82.     numero:=strtoint(InputBox('Introduce resultado','Aqui:',''));
  83.     {ShowMessage('Introduciste: '+ inttostr(numero));  }
  84.     suma:=strtoint(Edit1.Text)+strtoint(Edit2.Text);
  85.  
  86.   if suma = numero then
  87.     begin
  88. {aqui deberia incrementarse el valor}
  89.     elemento.aciertos:=elemento.aciertos+1;
  90.     elemento.intentos:=elemento.intentos+1;
  91.  
  92.     Edit4.Text:=inttostr(elemento.aciertos);
  93.    Edit5.Text:=inttostr(elemento.fallos);
  94.    Edit6.Text:=inttostr(elemento.intentos);
  95.     end
  96.   else
  97.      begin
  98. {aqui deberia incrementarse el valor}
  99.      elemento.fallos:=elemento.fallos+1;
  100.     elemento.intentos:=elemento.intentos+1;
  101.  
  102.      Edit4.Text:=inttostr(elemento.aciertos);
  103.    Edit5.Text:=inttostr(elemento.fallos);
  104.    Edit6.Text:=inttostr(elemento.intentos);
  105.      end
  106.  
  107.  
  108.  
  109.  
  110. end;
  111.  
  112. end.