Autor Beitrag
Flinthrc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36



BeitragVerfasst: Sa 15.04.06 16:23 
hallo!

ich möchte in einer while schleife hintereinander "wörter" erstellen (1.jpg, 2.jpg, 3.jpg, 4.jpg, usw.). Man soll selbst über ein Editfeld eingeben können ab welcher zahl die schleife beginnt und in einen anderen, mit welcher zahl sie endet.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var a, i:integer;
begin
  i:=strtoint(Edit4.Text);
  a:=strtoint(Edit5.Text);

while i = a do
begin
  i:=inttostr(i);
  SourceFile := Edit1.Text+i+Edit3.Text;
  i:=strtoint(i);
  i:=i+1;
...


Nur kommt jetzt bei dem "i:=inttostr(i);" ein Fehler (Inkompatible typen ...).

Was ist daran falsch??

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 15.04.06 16:26 
Du deklarierst i als integer und willst mit inttostr dieser Variable einen string zuweisen.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Flinthrc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36



BeitragVerfasst: Sa 15.04.06 16:26 
Und wie kann ich das Problem nun lösen?
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Sa 15.04.06 16:27 
// merk grad, dass Koller scho was geschrieben hat, aber ich sag halt dasselbe nochma:
i ist schon ein Integerwert, den brauchst du net erst umwandeln :zwinker:
|Edit| so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var a, i:integer;
begin
  i:=strtoint(Edit4.Text);
  a:=strtoint(Edit5.Text);

while i = a do
begin
  SourceFile := Edit1.Text + IntToStr(i) + Edit3.Text; //da muss das IntToStr hin
  inc(i);
...


Zuletzt bearbeitet von Danniolo am Sa 15.04.06 16:29, insgesamt 2-mal bearbeitet
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 15.04.06 16:27 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var a, i:integer;
begin
  i:=strtoint(Edit4.Text);
  a:=strtoint(Edit5.Text);

while i = a do
begin
  SourceFile := Edit1.Text+inttostr(i)+Edit3.Text;
  inc(i);

...

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 15.04.06 16:29 
Nimm doch eine for-Schleife dafür!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var a, i:integer;
begin
  i:=strtoint(Edit4.Text);
  a:=strtoint(Edit5.Text);

for i := 1 to a do
begin
  SourceFile := Edit1.Text+inttostr(i)+Edit3.Text;
  ...
end;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Sa 15.04.06 16:32 
dann müsste er die Forschleife so schreiben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var a, i:integer;
begin
  a:=strtoint(Edit5.Text);

for i := strtoint(Edit4.Text) To a do
Begin
  SourceFile := Edit1.Text + IntToStr(i) + Edit3.Text;
  [...]
End;


Zuletzt bearbeitet von Danniolo am Sa 15.04.06 16:33, insgesamt 1-mal bearbeitet
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 15.04.06 16:33 
Joah hast (ausnahmsweise) mal Recht! :zustimm:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot