Autor Beitrag
shrubman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Sa 06.11.04 16:20 
Ich möchte der Variable Z die Werte 1 bis 10 zuordnen aber das klappt nicht richtig :
Ich kann in der If schleife nur A einem Z wert zuordnen.... Hat jemand eine Idee
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.Button2Click(Sender: TObject);
var A,Wort:string;
    Z: array[0..10] of integer;
    I:integer;        // Deklaration
begin
Wort:=Label2.Caption;
A:=Edit2.Text;  // Wort und A zuordnen
For I:=0 to 10 do
begin
Z[I]:=I;
end;   // Z die Werte 0 bis 10 zuordnen
if
A=Wort[Z[1]] // PROBLEM !!!!!!!!! Ich kann nur Z[1] schreiben aber nicht Z[1..10]
then   // dann
begin
Label1.Caption:=Label1.Caption +A;    // in Label 1 schreiben
end else Label3.Caption:=Label3.Caption +A; // wenn nicht dann Label 3
end;


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.
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: Sa 06.11.04 16:38 
Wenn ich dich richtig verstanden habe, willt du einen String der Form

'12345678910' herausbekommen.

Das geht auch so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  i: Integer;
  s: String;
...
for i := 1 to 10 do
  s := s + IntToStr(i);


Dein Code funktioniert nicht, weil du die WERT-IN(z[i])-te Stelle deines Sourcestrings ausliest... der Ansatz ist falsch.

AXMD

btw: wär nett, wenn du den Quellcode einrücken könntest. Macht das ganze lesefreundlicher.
shrubman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Sa 06.11.04 16:58 
Nein das mein ich nicht so richtig... Ich wollte
A=Wort[Z]
in der if schleife, dass Z entweder 1,2,3,4,5,6,7,8,9,10 ist.... um somit alle buchstaben des wortes nach var "A" abzusuchen....
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 06.11.04 17:31 
1. Es gibt KEINE If-Schleifen!
2. Das End in Zeile 11 muss ans Ende
3. Der Index aus Zeile 13 muss I und nicht 1 lauten.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button2Click(Sender: TObject);
var 
    A, Wort:string;
    Z: array[0..10] of integer;
    I:integer;        // Deklaration
begin
    Wort:=Label2.Caption;
    A:=Edit2.Text;  // Wort und A zuordnen
    For I:=0 to 10 do
    begin
        if A=Wort[Z[1]] then   // // PROBLEM !!!!!!!!! Ich kann nur Z[1] schreiben aber nicht Z[1..10]
        begin
            Label1.Caption:=Label1.Caption +A;    // in Label 1 schreiben
        end 
        else 
        begin
            Label3.Caption:=Label3.Caption +A; // wenn nicht dann Label 3
        end 
    end;
end;


4. Wenn du wissen willst, ob A in Wort vorkommt:
ausblenden Delphi-Quelltext
1:
KommtVor := Pos(A, Wort) <> 0;					

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
shrubman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Sa 06.11.04 19:33 
danke!!!!!
shrubman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Sa 06.11.04 19:33 
jetzt klappts