Autor Beitrag
ConditionZero
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: Sa 02.12.06 22:27 
Abend,
Folgendes: Ich will ein Programm machen (bzw. das ist nur ein Teil davon) wo in einem Label ein Wert von einem Array[x] angezeigt wird. Nur soll dieser Wert per Zufall entschieden werden, also mein Array hat 15 Speicherpunkte die einen Konstanten Wert haben. Hier mein bisheriger Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TAnschlagzaehler.FormCreate(Sender: TObject);
begin
Time:= 60;
Zufallsstring[1]:= 'scYhbdX23byF';
Zufallsstring[2]:= 'nduc7dCXcjDnadD';
Zufallsstring[3]:= 'AbCdeFgHiJkLmNoP';
Zufallsstring[4]:= 'jnscuUDNdus887v';
Zufallsstring[5]:= 'vTBbtvdvRf43f34f';
Zufallsstring[6]:= '4f43fr5fFSf4fFREF4';
Zufallsstring[7]:= 'f43f5hZHgef5fgG';
Zufallsstring[8]:= 'FW3FSF4AVgefk';
Zufallsstring[9]:= 'JN8cehe8wk9Kl';
Zufallsstring[10]:= '8hscHD9co4dmwk';
Zufallsstring[11]:= 'mxcw87nNUDNkls';
Zufallsstring[12]:= 'i03rxmIMIdlKD0';
Zufallsstring[13]:= 'dui38NONJokos943';
Zufallsstring[14]:= 'JsHSD8nj8dnI';
Zufallsstring[15]:= 'd3nmdj8ebBHwndwd9';

TextLbl.Caption:= Zufallsstring[Random];
end;


Mein Array ist so deklariert: Zufallsstring: "Array [1..15] of String;"
Jetzt bekomm ich aber die Fehlermeldung "Inkompatible Typen: Integer und Extendet"

Aber ich habe nirgentwo einen Integer-Wert noch einen reellen Wert drinnen, kann mir da einer sagen was da los ist? Und wie ich das Problem behoben bekomm.

LG
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Sa 02.12.06 22:34 
Das liegt am Random! Du musst Definitionsbereich der Zufallszahlen noch festlegen!
Also Zufallsstring[Random(15)+1]; ;)
randomize; nicht vergessen!!
ConditionZero Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 190

Win XP
Delphi 7 PE, C++ (Dev-C++), HTML+PHP (Dreamweaver MX), JavaScript(MS FrontPage)
BeitragVerfasst: Sa 02.12.06 22:43 
Ja aber wenn ich [Random(15)+1] eingebe kommt immer das erste weil das Array ja nur bis 15 geht und dann fängts wieder bei 1 an wenns um 1 erhöht wird also kommt immer der erste, oder irre ich mich da? aufjedenfall muss es so sein, dass bei jedem mal wenn man das programm startet ein anderer wert dasteht und der bleibt da aber auch bis man das proggi wieder zumacht oder einen Button drückt... das muss ich mir noch überlgen LoL


Edit: Ok, ich hab Randomize; vergessen ^^
was macht bei dem [Random(15)+1] die 15 und was die 1? den befehl blick ich nicht wirklich
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Sa 02.12.06 23:42 
Random markieren und auf F1 drücken (in Delphi, nich im Browser)!

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.