filmov
tv
Tutorial Visual Basic 6 HD (Slot Machine)

Показать описание
Vi lascio i codici per la SlotMachine qui sotto se avete domande chiedete pure:
Private Sub Command1_Click()
Label1.Caption = Int(Rnd * 10)
Label2.Caption = Int(Rnd * 10)
Label3.Caption = Int(Rnd * 10)
If (Label1.Caption = 7) Or (Label2.Caption = 7) Or (Label3.Caption = 7) Then
won.Caption = won.Caption + 1
MsgBox "Hai Vinto!", vbInformation, "Vincitore"
Else
Beep
End If
End SUb
Private Sub Command2_Click()
unload Me
End Sub
Privavate Sub form_queryunload(cancel As Integer, unloadme As Integer)
Dim sFile As String
Dim Score As String
Dim iFileNum As Integer
iFileNum = FreeFile
Open sFile For Output As iFileNum
Write #iFileNum, Score
Close #iFileNum
End Sub
Private Sub Form_Load()
On Error GoTo NoFile
Randomize
Dim sFile As String
Dim blank As String
Dim iScore As String
Dim nScore As String
Dim iFileNum As Integer
iFileNum = FreeFile
Open sFile For Input As iFileNum
Line Input #iFileNum, blank
Line Input #iFileNum, iScore
Line Input #iFileNum, nScore
Close #iFileNum
NoFIle
If Err.Number = 6 Then
iScore = 0
nScore = 0
iFileNum = FreeFile
Open sFile For Output As iFileNum
Weite #FileNum, Score
Close #FileNum
EndIf
End SUb
End SUb
Private Sub Command1_Click()
Label1.Caption = Int(Rnd * 10)
Label2.Caption = Int(Rnd * 10)
Label3.Caption = Int(Rnd * 10)
If (Label1.Caption = 7) Or (Label2.Caption = 7) Or (Label3.Caption = 7) Then
won.Caption = won.Caption + 1
MsgBox "Hai Vinto!", vbInformation, "Vincitore"
Else
Beep
End If
End SUb
Private Sub Command2_Click()
unload Me
End Sub
Privavate Sub form_queryunload(cancel As Integer, unloadme As Integer)
Dim sFile As String
Dim Score As String
Dim iFileNum As Integer
iFileNum = FreeFile
Open sFile For Output As iFileNum
Write #iFileNum, Score
Close #iFileNum
End Sub
Private Sub Form_Load()
On Error GoTo NoFile
Randomize
Dim sFile As String
Dim blank As String
Dim iScore As String
Dim nScore As String
Dim iFileNum As Integer
iFileNum = FreeFile
Open sFile For Input As iFileNum
Line Input #iFileNum, blank
Line Input #iFileNum, iScore
Line Input #iFileNum, nScore
Close #iFileNum
NoFIle
If Err.Number = 6 Then
iScore = 0
nScore = 0
iFileNum = FreeFile
Open sFile For Output As iFileNum
Weite #FileNum, Score
Close #FileNum
EndIf
End SUb
End SUb