Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Guardar el valor de un EDIT en un fichero de texto (https://www.clubdelphi.com/foros/showthread.php?t=39315)

creus 16-01-2007 22:39:57

Guardar el valor de un EDIT en un fichero de texto
 
Hola a todos,

Necesito guardar el valor de un EDIT en un archivo de texto.

De la misma manera que si quisieramos guardar el valor de un LISTBOX pondríamos el siguiente código,

Código Delphi [-]
   LISTBOX.Items.SaveToFile ('NombreArchivo'+'.extension');

Necesito guardar el valor de un Edit, pero no tiene la propiedad SaveToFile.

Gracias por la ayuda de nuevo.

dec 16-01-2007 22:57:50

Hola,

Código Delphi [-]
var
  t: TStrings;
begin
  t := TStringList.Create;
  try
    t.Text = Edit1.Text;
    t.SaveToFile('C:\edit1.txt');
  finally
    t.Free;
  end;
end;

roman 16-01-2007 23:02:56

Otra forma:

Código Delphi [-]
var
  Archivo: TextFile;

begin
  AssignFile(Archivo, 'archivo.txt');
  Rewrite(Archivo);
  WriteLn(Archivo, Edit1.Text);
  CloseFile(Archivo);
end;

// Saludos


La franja horaria es GMT +2. Ahora son las 17:23:16.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi