Computer Hardware Forum - TweakPC

Computer Hardware Forum - TweakPC (https://www.tweakpc.de/forum/)
-   Programmiersprachen (https://www.tweakpc.de/forum/programmiersprachen/)
-   -   Lucky 7 (https://www.tweakpc.de/forum/programmiersprachen/5352-lucky-7-a.html)

Gartenschlauch 09.01.2003 13:42

Lucky 7
 
ich hab mit dem buch von visual basic ein programm erstellt das "Lucky 7" heist. das programm soll 3 beliebige zahlen zwischen 0 und 9 erstellen. wenn die zahl 7 kommt soll es ein bild anzeigen.ich habs dann mal selber erstellt nur klappt es nicht wenn ich auch neuer versuch klicke kommt immer 0. ich hab mal kopiert wie ich es geschrieben habe ich hoffe ihr findet den fehler:

Private Sub Command1_Click()
Image1.Visible = False
Label1.Caption = Int(Rnt * 10)
Label2.Caption = Int(Rnt * 10)
Label3.Caption = Int(Rnt * 10)

If (Label1.Caption = 7) Or (Label2.Caption = 7) _
Or (Label3.Caption = 7) Then Image1.Visible = True
Beep

End Sub

sys3 09.01.2003 20:22

Ich kenne VB zwar nicht, aber vielleicht muss man den Zufallszahlengenerator vor der Benutzung initialisieren.

Ciao,
sys3

InFlames 09.01.2003 21:34

Jo is in Delphi so. Random muss durch Randomize initialisiert werden.

asdfasdf 29.05.2012 15:03

AW: Lucky 7
 
Image1.Visible = False 'Münzen Verdecken
Label1.Caption = Int(Rnd * 10) 'Zahlen wählen
Label2.Caption = Int(Rnd * 10)
Label3.Caption = Int(Rnd * 10)
'falls zwei der Zahlen 7 sind, Münzen anzeigen
If (Label1.Caption = 7) And (Label2.Caption = 7) _
Or (Label1.Caption = 7) And (Label3.Caption = 7) _
Or (Label2.Caption = 7) And (Label3.Caption = 7) Then
Image1.Visible = True
Beep
End If

So gehts ;) muss ich grad beim probearbeiten lösen bin schon viel weiter komm aber an einer stelle nicht weiter.... :(

Tweak-IT 04.06.2012 12:14

AW: Lucky 7
 
Evtl. eleganter und übersichtlicher mit einem select case Baustein?

[url=http://msdn.microsoft.com/de-de/library/cy37t14y%28v=vs.80%29.aspx]Select...Case-Anweisung (Visual Basic)[/url]


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:33 Uhr.

Powered by vBulletin® Version 3.8.10 (Deutsch)
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.5.2 ©2010, Crawlability, Inc.