Ir para conteúdo
Fórum Script Brasil
  • 0

Buscar Texto No Txt (Resolvido)


nightmare

Pergunta

6 respostass a esta questão

Posts Recomendados

  • 0

Não sei se é isso, mas para ler txt, eu faço assim:

var

txt:TextFile;

a,b,path:string;

begin

path:='C:\Teste\';

if fileexists('C:\Teste\Meu.txt') then begin

  AssignFile(txt, path);

  reset(txt)

  Readln(txt, a);

  Readln(txt, cool.gif;

Closefile(txt);

end;

end;

As variáveis a e b são carregadas, pelo que estiver sido lido pelo arquivo txt.

Será que é isto? Será? Será? Será?(Não é skol, é delphi)

Link para o comentário
Compartilhar em outros sites

  • 0

Olá nightmare,

é tipo assim:

criei um arquivo texto chamado login.txt com o cadastro de usuario:

Login Senha

Jose12345678

Mariateste

Pedro001122

etc,

etc,

etc...

no delphi dois edits: EditLogin e EditSenha, e um buttom:

no OnClick do button coloque assim:

procedure TForm1.Button1Click(Sender: TObject);
var
  ArqTxt : TextFile;
  Linha, Login, senha : string;
  i, nx1, nx2 : Integer;
  log : boolean;
begin
  AssignFile(ArqTxt,'C:\login.txt');
  Reset(ArqTxt);
  log := False;

  while not eof(ArqTxt) do begin
     Readln(ArqTxt, Linha);
     nx1 := Length(Trim(EditLogin.text));
     nx2 := Length(Linha) - nx1;
     Login := Copy(Linha,1,nx1);
     Senha := Copy(Linha,nx1+1,nx2);
     if trim(EditLogin.text) = Login then begin
        Log := True;
        if EditSenha.Text <> Senha then begin
           ShowMessage('Senha incorreta!');
           Break;
        end;
     end;
  end;

  Linha := '';
  Closefile(ArqTxt);

  if log then begin
     Application.CreateForm(TForm2, Form2);
     Application.Run;
  end;

  if not log then
     ShowMessage('Usuario não cadastrado!');

end;

Autor Progr'amador. hehehe biggrin.gif

Abs.

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,7k
×
×
  • Criar Novo...