Guten Tag
ich habe programmiert, dass wenn man auf einen Button klickt, eine zufällige Zahl ausgelost wird und entsprechend der Zahl dann das Bild angezeigt werden soll.
2 Proobleme:
-Der Button reagiert beim ersten mal IMMER erst nach dem 3. mal draufklicken.
-zwischendurch kurze Aussetzer
Hier der Code
Delphi-Quellcode:
//Zufallsprinzip + Manuell weiterklicken
procedure TfrmMain.btnVorClick(Sender: TObject);
begin
//1ten 3 DurAkkorde
if Akkordwahl = 1 then
begin
Lotto := random(4);
case Lotto of
1:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\C-Dur.jpg');
lbnAkkord.Caption := ('C-Dur');
end;
2:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Dur.jpg');
lbnAkkord.Caption := ('D-Dur');
end;
3:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\G-Dur.jpg');
lbnAkkord.Caption := ('G-Dur');
end;
end;
end;
// Dur-Akkorde
if Akkordwahl = 2 then
begin
Lotto := random(8);
case Lotto of
7:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\C-Dur.jpg');
lbnAkkord.Caption := ('C-Dur');
end;
1:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Dur.jpg');
lbnAkkord.Caption := ('D-Dur');
end;
2:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Dur.jpg');
lbnAkkord.Caption := ('A-Dur');
end;
3:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Dur.jpg');
lbnAkkord.Caption := ('E-Dur');
end;
4:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\G-Dur.jpg');
lbnAkkord.Caption := ('G-Dur');
end;
5:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Dur.jpg');
lbnAkkord.Caption := ('F-Dur');
end;
6:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Dur.jpg');
lbnAkkord.Caption := ('B-Dur');
end;
end;
end;
// 1ten 3 Mollakkorde
if Akkordwahl = 3 then
begin
Lotto := random(4);
case Lotto of
1:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Moll.jpg');
lbnAkkord.Caption := ('D-Moll');
end;
2:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Moll.jpg');
lbnAkkord.Caption := ('A-Moll');
end;
3:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Moll.jpg');
lbnAkkord.Caption := ('E-Moll');
end;
end;
end;
// Moll - Akkorde
if Akkordwahl = 4 then
begin
Lotto := random(6);
case Lotto of
1:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Moll.jpg');
lbnAkkord.Caption := ('D-Moll');
end;
2:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Moll.jpg');
lbnAkkord.Caption := ('A-Moll');
end;
3:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Moll.jpg');
lbnAkkord.Caption := ('E-Moll');
end;
4:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Moll.jpg');
lbnAkkord.Caption := ('F-Moll');
end;
5:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Moll.jpg');
lbnAkkord.Caption := ('B-Moll');
end;
end;
end;
//Dur + Moll Akkorde
if Akkordwahl = 5 then
begin
Lotto := random(13);
case Lotto of
1:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\C-Dur.jpg');
lbnAkkord.Caption := ('C-Dur');
end;
2:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Dur.jpg');
lbnAkkord.Caption := ('D-Dur');
end;
3:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Dur.jpg');
lbnAkkord.Caption := ('A-Dur');
end;
4:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Dur.jpg');
lbnAkkord.Caption := ('E-Dur');
end;
5:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\G-Dur.jpg');
lbnAkkord.Caption := ('G-Dur');
end;
6:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Dur.jpg');
lbnAkkord.Caption := ('F-Dur');
end;
7:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Dur.jpg');
lbnAkkord.Caption := ('B-Dur');
end;
8:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Moll.jpg');
lbnAkkord.Caption := ('D-Moll');
end;
9:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Moll.jpg');
lbnAkkord.Caption := ('A-Moll');
end;
10:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Moll.jpg');
lbnAkkord.Caption := ('E-Moll');
end;
11:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Moll.jpg');
lbnAkkord.Caption := ('F-Moll');
end;
12:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Moll.jpg');
lbnAkkord.Caption := ('B-Moll');
end;
end;
end;
// Dur7Akkord
if Akkordwahl = 6 then
begin
Lotto := random(8);
case Lotto of
1:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\C-Dur7.jpg');
lbnAkkord.Caption := ('C-Dur 7');
end;
2:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Dur7.jpg');
lbnAkkord.Caption := ('D-Dur 7');
end;
3:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Dur7.jpg');
lbnAkkord.Caption := ('A-Dur 7');
end;
4:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Dur7.jpg');
lbnAkkord.Caption := ('E-Dur 7');
end;
5:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\G-Dur7.jpg');
lbnAkkord.Caption := ('G-Dur 7');
end;
6:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Dur7.jpg');
lbnAkkord.Caption := ('F-Dur 7');
end;
7:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Dur7.jpg');
lbnAkkord.Caption := ('B-Dur 7');
end;
end;
end;
//Moll7Akkord
if Akkordwahl = 7 then
begin
Lotto := random(6);
case Lotto of
1:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Moll7.jpg');
lbnAkkord.Caption := ('D-Moll 7');
end;
2:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Moll7.jpg');
lbnAkkord.Caption := ('A-Moll 7');
end;
3:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Moll7.jpg');
lbnAkkord.Caption := ('E-Moll 7');
end;
4:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Moll7.jpg');
lbnAkkord.Caption := ('F-Moll 7');
end;
5:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Moll7.jpg');
lbnAkkord.Caption := ('B-Moll 7');
end;
end;
end;
//Alle Akkorde
if Akkordwahl = 8 then
begin
Lotto := random(25);
case Lotto of
24:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\C-Dur.jpg');
lbnAkkord.Caption := ('C-Dur');
end;
1:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Dur.jpg');
lbnAkkord.Caption := ('D-Dur');
end;
2:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Dur.jpg');
lbnAkkord.Caption := ('A-Dur');
end;
3:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Dur.jpg');
lbnAkkord.Caption := ('E-Dur');
end;
4:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\G-Dur.jpg');
lbnAkkord.Caption := ('G-Dur');
end;
5:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Dur.jpg');
lbnAkkord.Caption := ('F-Dur');
end;
6:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Dur.jpg');
lbnAkkord.Caption := ('B-Dur');
end;
7:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\C-Dur7.jpg');
lbnAkkord.Caption := ('C-Dur 7');
end;
8:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Dur7.jpg');
lbnAkkord.Caption := ('D-Dur 7');
end;
9:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Dur7.jpg');
lbnAkkord.Caption := ('A-Dur 7');
end;
10:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Dur7.jpg');
lbnAkkord.Caption := ('E-Dur 7');
end;
11:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\G-Dur7.jpg');
lbnAkkord.Caption := ('G-Dur 7');
end;
12:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Dur7.jpg');
lbnAkkord.Caption := ('F-Dur 7');
end;
13:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Dur7.jpg');
lbnAkkord.Caption := ('B-Dur 7');
end;
14:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Moll.jpg');
lbnAkkord.Caption := ('D-Moll');
end;
15:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Moll.jpg');
lbnAkkord.Caption := ('A-Moll');
end;
16:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Moll.jpg');
lbnAkkord.Caption := ('E-Moll');
end;
17:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Moll.jpg');
lbnAkkord.Caption := ('F-Moll');
end;
18:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Moll.jpg');
lbnAkkord.Caption := ('B-Moll');
end;
19:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\D-Moll7.jpg');
lbnAkkord.Caption := ('D-Moll 7');
end;
20:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\A-Moll7.jpg');
lbnAkkord.Caption := ('A-Moll 7');
end;
21:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\E-Moll7.jpg');
lbnAkkord.Caption := ('E-Moll 7');
end;
22:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\F-Moll7.jpg');
lbnAkkord.Caption := ('F-Moll 7');
end;
23:begin
imgAkkord.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Pics\B-Moll7.jpg');
lbnAkkord.Caption := ('B-Moll 7');
end;
end;
end;
end;
danke für die Hilfe
PS: wie kann man das vieleict vereinfachen?