vb 6 code the lucky 7 game

2
VB 6.0 GAME PROJECT by Arie Musbandi The Lucky 7 Membuat game sederhana dimana ditampilkan 3 angka secara acak, jika muncul angka 7 maka dianggap beruntung, tampilan form nya sebagai berikut : Property Set Form1 BorderStyle Caption 1-Fixed Single Lucky 7 Label1, Label2, Label3 Alignment BorderStyle Caption Font 2-Center 1-Fixed Single 0 Font Style= Bold; Size =72 Label 4 Alignment BorderStyle Caption Font 2-Center 1-Fixed Single Let’s Play Size = 24 Command1 Caption Round VB Code : Private Sub Command1_Click() Dim A, B, C As Integer Dim Luck As Integer Luck = 0 A = CInt(Rnd() * 9) B = CInt(Rnd() * 9) C = CInt(Rnd() * 9) Label1.Caption = A Label2.Caption = B Label3.Caption = C If A = 7 Then Luck = Luck + 1 Label1.BackColor = vbYellow Else If C = 7 Then Luck = Luck + 1 Label3.BackColor = vbYellow Else Label3.BackColor = &H80000005 End If If Luck > 0 Then Label4.Caption = "YOU WIN!" & vbCrLf & Luck & " Good Luck!" Else Label4.Caption = "YOU LOST! Label 1 Label 2 Label 3 Label 4 Command 1 Form1

Upload: arie-musbandi

Post on 01-Feb-2016

217 views

Category:

Documents


0 download

DESCRIPTION

Source Code VB 6 Membuat Game Lucky 7

TRANSCRIPT

Page 1: VB 6 Code the Lucky 7 Game

VB 6.0 GAME PROJECT by Arie Musbandi

The Lucky 7

Membuat game sederhana dimana ditampilkan 3 angka secara acak, jika muncul angka 7 maka dianggap beruntung, tampilan form nya sebagai berikut :

Property SetForm1 BorderStyle

Caption1-Fixed SingleLucky 7

Label1, Label2, Label3 AlignmentBorderStyleCaptionFont

2-Center1-Fixed Single0Font Style= Bold; Size =72

Label 4 AlignmentBorderStyleCaptionFont

2-Center1-Fixed SingleLet’s PlaySize = 24

Command1 Caption Round

VB Code :Private Sub Command1_Click()Dim A, B, C As IntegerDim Luck As IntegerLuck = 0A = CInt(Rnd() * 9)B = CInt(Rnd() * 9)C = CInt(Rnd() * 9)Label1.Caption = ALabel2.Caption = BLabel3.Caption = C

If A = 7 Then Luck = Luck + 1 Label1.BackColor = vbYellowElse Label1.BackColor = &H80000005End If

If B = 7 Then Luck = Luck + 1 Label2.BackColor = vbYellowElse Label2.BackColor = &H80000005End If

If C = 7 Then Luck = Luck + 1 Label3.BackColor = vbYellowElse Label3.BackColor = &H80000005End If

If Luck > 0 Then Label4.Caption = "YOU WIN!" & vbCrLf & Luck & " Good Luck!"Else Label4.Caption = "YOU LOST! Bad Luck!"End IfEnd Sub

Label1

Label2

Label3

Label4

Command1

Form1

Page 2: VB 6 Code the Lucky 7 Game