Autor Beitrag
noctua
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 170



BeitragVerfasst: Di 21.06.05 17:12 
ich weiß nicht, bin ich blind oder einfach nur doof

ich habe mir n dynamisches array gemacht
ausblenden Delphi-Quelltext
1:
var aAmpfaengerMail: array of string;					

dem array eine länge zugewiesen
ausblenden Delphi-Quelltext
1:
SetLength(aAmpfaengerMail, groesse);					

habe was reingeschrieben
ausblenden Delphi-Quelltext
1:
aAmpfaengerMail[i] := AmpfaengerMail;					

nun will ich den inhalt auslesen
ausblenden Delphi-Quelltext
1:
Label1.Caption :=  aAmpfaengerMail[2];					


und was passiert? ne FEHLERMELDUNG, warum? im forum finde ich auch nix, ich verzweifle :'( :'( :'( :'( :cry: :cry: :cry:

Moderiert von user profile iconAXMD: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconChristian S.: Topic aus Sonstiges verschoben am Di 21.06.2005 um 18:55

_________________
Am ende sterben eh alle ................
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Di 21.06.05 17:14 
Wie groß ist Größe? 2? Dann muss ein Fehler kommen, weil dynamische Arrays Indizes von 0 bis Anzahl -1 haben.

AXMD
noctua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 170



BeitragVerfasst: Di 21.06.05 17:16 
nein die größe is 20 ....

_________________
Am ende sterben eh alle ................
MrFox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 208

WIN 2000 Professional, Ubuntu 5.10
D3 Prof, D7 Pers, D2005 Pers, Java (Eclipse)
BeitragVerfasst: Di 21.06.05 17:16 
Wie groß ist denn das Array (zum Zeitpunkt der Abfrage)? Beachte: Ein Array mit 3 Einträgen kann über die Indizes 0,1 und 2 angesprochen werden.
//EDIT: Des war zu spät.
Aber man beachte:

Wie lautet die Fehlermeldung? Evtl. hast du das Array an der falschen Stelle deklariert.

_________________
Das Leben auf der Erde mag zwar teuer sein, aber eine jährliche Rundreise um die Sonne ist gratis mit dabei.


Zuletzt bearbeitet von MrFox am Di 21.06.05 17:18, insgesamt 1-mal bearbeitet
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Di 21.06.05 17:16 
Ist das der komplette Quelltext? Weil der ist richtig - da muss was anderes Falsch sein. Zeig mal den ganzen Code

AXMD
noctua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 170



BeitragVerfasst: Di 21.06.05 17:18 
ausblenden Delphi-Quelltext
1:
2:
3:
var aAmpfaengerName: array of string;
var aAmpfaengerMail: array of string;
var aAbsenderName: array of string;



ausblenden volle Höhe Delphi-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:
procedure KontakteLesenSenden();
const
  olFolderContacts = $0000000A;
var
  AmpfaengerName,AmpfaengerMail,AbsenderName :string;
  outlook, NameSpace, Contacts, Contact: OleVariant;
  i, groesse: Integer;
begin
  outlook := CreateOleObject('Outlook.Application');
  NameSpace := outlook.GetNameSpace('MAPI');

  Contacts := NameSpace.GetDefaultFolder(olFolderContacts);

  groesse := Contacts.Items.Count;    // definiert die größen der einzelnen arrays
  SetLength(aAmpfaengerName, groesse);
  SetLength(aAmpfaengerMail, groesse);
  SetLength(aAbsenderName, groesse);

  for i := 0 to Contacts.Items.Count-1 do
  begin
    Contact := Contacts.Items.Item(i);

    AmpfaengerName := Contact.FullName;
    AmpfaengerMail := Contact.Email1Address;
    AbsenderName := GetUserName;

    aAmpfaengerName[i] := AmpfaengerName;
    aAmpfaengerMail[i] := AmpfaengerMail;
    aAbsenderName[i] := AbsenderName;
  end;

  Outlook := UnAssigned;
end;


ausblenden Delphi-Quelltext
1:
Label1.Caption :=  aAmpfaengerMail[1];					


also das is der code, ich hoffe du kannst mir helfen, denn ich bin vollkommen veriwrrt

_________________
Am ende sterben eh alle ................


Zuletzt bearbeitet von noctua am Di 21.06.05 17:31, insgesamt 1-mal bearbeitet
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Di 21.06.05 17:21 
2 Dinge:

1.) Ich finde deine Codezeilen mit dem Label1.Caption := ... nicht mehr :gruebel:

und 2.) Warum brauchst du Zwischenvariablen und weist nicht direkt auf die Array-Felder zu (Zeilen 23-29)?

AXMD
noctua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 170



BeitragVerfasst: Di 21.06.05 17:26 
1. Label1.Caption := ... steht weiter unten weil die array global sind :oops:

2. ups gutes argument, liegt wohl daran, dass ich vorher ohne das array gearbeitet habe

_________________
Am ende sterben eh alle ................
noctua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 170



BeitragVerfasst: Di 21.06.05 17:32 
hab die zwischen variablen entfernt, es geht trotzdem nicht, leider

_________________
Am ende sterben eh alle ................
noctua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 170



BeitragVerfasst: Di 21.06.05 17:37 
hab den fehler entdeckt .....

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
for i := 1 to Contacts.Items.Count do
  begin
    Contact := Contacts.Items.Item(i);

    aAmpfaengerName[i-1] := Contact.FullName;
    aAmpfaengerMail[i-1] := Contact.Email1Address;
    aAbsenderName[i-1] := GetUserName;

  end;


danke du hast mich auf den weg gebracht :D ichd enke wieder klar

_________________
Am ende sterben eh alle ................
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 21.06.05 18:44 
Klar denken vielleicht, aber mit einem Knoten im Hirn. Lass die Schelife doch gleich von 0 bis Count - 1 laufen, dann ersparst du dir die Subtraktion bei den Indizes.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 0 to Listbox1.Items.Count - 1 do
begin
  xyz[i];
end;

So macht man das normalerweise. :roll: