AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Habe ich Knöpfe auf den Augen - Please help

Ein Thema von JimmyB · begonnen am 17. Apr 2022 · letzter Beitrag vom 18. Apr 2022
 
Benutzerbild von FriedrichAT
FriedrichAT

Registriert seit: 25. Mai 2019
Ort: Wien
35 Beiträge
 
Delphi 12 Athens
 
#4

AW: Habe ich Knöpfe auf den Augen - Please help

  Alt 17. Apr 2022, 23:20
Hallo
Zitat:
Habe ich Knöpfe auf den Augen - Please help
Copy -> Paste und nicht lesen bzw. -> F9 ist dein Freund

Delphi-Quellcode:
unit Unit3;

interface

uses
  Winapi.Windows, Winapi.Messages,
  System.SysUtils, System.Variants, System.Classes,
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    RichEdit1: TRichEdit;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private { Private-Deklarationen }
  public { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
  // Step 1 - Declare Variables
var
  myfile : textfile;
  sLine : string;

begin
  // Step 2 - check if filename exist
  if not FileExists( 'teams.txt' ) then
  begin
    ShowMessage('Datei nicht gefunden') ;
    exit;
  end
  else
    ShowMessage('Die Datei ist vorhanden') ;
  // Step 3 - Assign File to our variable
  AssignFile( myfile, 'teams.txt');

  //Step 4: Put the pointer to the top of the textfile
  Reset( myfile );

  //Step 5: Loop through our textfile
  //You must use BEGIN and END
  while NOT eof(myfile) do
  begin
    //Step 6: Get each line of text file into string varibale
    readln(myfile , sLine);
    RichEdit1.Lines.Add( sLine) ;
  end; //end of our while loop

  //Step 7: Close the association with the text file
  CloseFile (myfile);
end;

// oder...
procedure TForm1.Button2Click(Sender: TObject);
var SL: TStrings;
begin
  if not FileExists( 'teams.txt' ) then
  begin
    ShowMessage('Datei nicht gefunden') ;
    exit;
  end
  else
  begin
    ShowMessage('Die Datei ist vorhanden') ;
    SL:= TStringList.Create;
    try
      SL.LoadFromFile('teams.txt');
      RichEdit1.Text:= SL.Text;
    finally
      SL.Free;
    end;
  end;
end;

initialization
  ReportMemoryLeaksOnShutdown:= True;
end.
Friedrich
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:21 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz