Autor Beitrag
Chatfix
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mo 07.10.02 18:45 
hi, hab ein einfaches problem, ich komm aber nicht auf die lösung..
bitte fragt ncht wieso ich s ein sinnlosen program schreiben möchte.. es soll die Postleitzahlen aus einer File auslesen die so Aufgebaut ist:

ausblenden Quelltext
1:
2:
00000Ort1
00001Ort2


die PLZ solln dann in eine combobox geladen werden.

habe dafür folgenden code, er bringt keinen fehler aber es steht nix in der combobox :(...

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    ComboBox1: TComboBox;
    procedure plz_auslesen;
    procedure FormActivate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    plz_file: String;
    plz: TStringList;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure Tform1.plz_auslesen;
var i,j: Integer;
    line: String;
begin
  if fileexists(plz_file) then
    begin
      plz.LoadFromFile(plz_file);
      for i := 1 to plz.Count do
        begin
          for j := 1 to 5 do
            begin
              line := line + plz[i][j];
            end;
          combobox1.Items.Add(line);
        end;
    end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  plz_file := paramstr(0)+'plz.plz';
  plz_auslesen;
end;

end.

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 07.10.02 18:57 
Eventuell hilft es, wenn du die Stringliste erstmal erzeugst. :roll:
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mo 07.10.02 19:02 
ach du scheise *g* wäre vieleicht eine idee :p
ich bin halt immernoch in gedanken bei meiner theorieprüfung morgen *gg*

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 07.10.02 19:02 
Hi!

ParamStr(0) gibt bei mir den Namen der exe-Datei. Kann es daran liegen?

MfG,
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mo 07.10.02 19:08 
ähm ja *mal nachobenschautzundrotwird*
da ziehtz einem ja die schuhe aus.. so einfache fehler.. sicher liegt es daran es muss ja heissen extractfilepath(paramstr(0)) *ggg*

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Alfons-G
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 307

Win XP Prof, Linux, Win 7
D5 Prof, D7 Architect, D2005 Architect, D2007 Architect
BeitragVerfasst: Mo 07.10.02 19:08 
:wave:
ParamStr(0) ist der vollständige Name und Pfad der Exe-Datei.
Um im Programmverzeichnis eine Datei "PLZ.plz" zu lesen, muß man den Pfad extrahierenplz_file := ExtractFilePath(ParamStr(0)) + 'plz.plz';

:idea:

_________________
Alfons Grünewald
Chatfix Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mo 07.10.02 19:15 
ok funzt jetzt... danke.. nur so ich nebenbei: ich stelle gerne newbiefragen LOL

nur so für den dens interessiert.. mein code sieht jetzt so aus:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit2: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    ComboBox1: TComboBox;
    procedure plz_auslesen;
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    plz_file: String;
    plz: TStrings;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure Tform1.plz_auslesen;
var i,j: Integer;
    line: String;
begin
  if fileexists(plz_file) then
    begin
      plz.Clear;
      plz.LoadFromFile(plz_file);
      for i := 0 to plz.Count-1 do
        begin
          for j := 1 to 5 do
            begin
              line := line + plz[i][j];
            end;
          combobox1.Items.Add(line);
          line := '';
        end;
    end;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  plz := Tstringlist.Create;
  plz_file := extractfilepath(paramstr(0))+'plz.plz';
  plz_auslesen;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  plz.Free;
end;

end.

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce