TUTORIAL PEMBUATAN GAMES G-NATO
2. Kemudian buat project dengan tiga Button “About Us”, “Next”, “Exit” dan Label 1 buat Nama Program.
Dengan listing pada Button untuk memunculkan dan menghilangkan form selanjutnya atau
yang setelah muncul.
Public Class Form1
Private Sub
Button1_Click(sender As System.Object, e As
System.EventArgs) Handles
Button1.Click
Form2.Show()
Me.Hide()
End Sub
Private Sub
Button2_Click(sender As System.Object, e As
System.EventArgs) Handles
Button2.Click
Form3.Show()
Me.Hide()
End Sub
Private Sub
Button3_Click(sender As System.Object, e As
System.EventArgs) Handles
Button3.Click
If MsgBox("Are you
sure for exit?", vbQuestion + vbYesNo, "Konfirmasi")
= vbYes Then
End
End If
End Sub
End Class
3.Langkah selanjutnya ialah mengerjakan program games pada form3. Dengan label sebanyak 4 buat Judul, Point, Nama, Alamat dan buat 3 textbox. setelah itu buat radiobutton sebanyak buat button sebanyak 10 untuk pengulangan sebanyak 3 kali kesempatan dan button exit.
Listingnya sebagai
berikut
Public Class Form3
Private Sub
Button2_Click(sender As System.Object, e As
System.EventArgs) Handles
Button2.Click
If Timer1.Enabled = True
Then
Timer1.Enabled = False
End If
If RadioButton1.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = (TextBox1.Text) - (RadioButton1.Text)
Button1.Visible = False
Button2.Visible = False
Button3.Visible = True
Button5.Visible = True
Button6.Visible = False
Button7.Visible
= True
Button8.Visible = False
End If
End If
If RadioButton2.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = TextBox1.Text - RadioButton2.Text
Button1.Visible = False
Button2.Visible = False
Button5.Visible = True
Button6.Visible = False
Button7.Visible = True
Button8.Visible = False
End If
End If
If RadioButton3.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = TextBox1.Text - RadioButton3.Text
Button1.Visible = False
Button2.Visible = False
Button5.Visible = True
Button6.Visible = False
Button7.Visible = True
Button8.Visible = False
End If
End If
End Sub
Private Sub
Button4_Click(sender As System.Object, e As
System.EventArgs) Handles
Button4.Click
Me.Close()
End Sub
Private Sub
Button3_Click(sender As System.Object, e As
System.EventArgs) Handles
Button3.Click
TextBox1.Text = "50000"
TextBox2.Text = Nothing
TextBox3.Text = Nothing
Label5.Text = Nothing
Label6.Text = Nothing
Label7.Text = Nothing
Button1.Visible = True
Button2.Visible = True
Button3.Visible = True
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
Button8.Visible = False
End Sub
Private Sub Timer1_Tick(sender
As System.Object,
e As System.EventArgs)
Handles Timer1.Tick
Label5.Text = Int(Rnd() * 10)
Label6.Text = Int(Rnd() * 10)
Label7.Text = Int(Rnd() * 10)
End Sub
Private Sub
Button1_Click(sender As System.Object, e As
System.EventArgs) Handles
Button1.Click
If TextBox2.Text = ""
Then
MsgBox("please choose the bet")
End If
If TextBox2.Text = ""
Then
MsgBox("please entry your name")
End If
If TextBox3.Text = ""
Then
MsgBox("please entry your address")
Else
Timer1.Enabled = True
End If
End Sub
Private Sub
TextBox1_KeyPress(sender As Object, e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _
AndAlso Not
IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub
Private Sub
Form3_Load(sender As System.Object, e As
System.EventArgs) Handles
MyBase.Load
Button1.Visible = True
Button2.Visible = True
Button3.Visible = True
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
Button8.Visible = False
End Sub
Private Sub
Button5_Click(sender As System.Object, e As
System.EventArgs) Handles
Button5.Click
If TextBox1.Text = ""
Then
MsgBox("please entry your number")
End If
If TextBox2.Text = ""
Then
MsgBox("please entry your name")
End If
If TextBox3.Text = ""
Then
MsgBox("please entry your address")
Else
Timer1.Enabled = True
End If
End Sub
Private Sub
Button7_Click(sender As System.Object, e As System.EventArgs) Handles
Button7.Click
If Timer1.Enabled = True
Then
Timer1.Enabled = False
End If
If RadioButton1.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = TextBox1.Text - RadioButton1.Text
Button1.Visible = False
Button2.Visible = False
Button5.Visible = False
Button6.Visible = True
Button7.Visible = False
Button8.Visible = True
End If
End If
If RadioButton2.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = TextBox1.Text - RadioButton2.Text
Button1.Visible = False
Button2.Visible = False
Button5.Visible = False
Button6.Visible = True
Button7.Visible = False
Button8.Visible = True
End If
End If
If RadioButton3.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = TextBox1.Text - RadioButton3.Text
Button1.Visible = False
Button2.Visible = False
Button5.Visible = False
Button6.Visible = True
Button7.Visible = False
Button8.Visible = True
End If
End If
End Sub
Private Sub
Button6_Click(sender As System.Object, e As
System.EventArgs) Handles
Button6.Click
If TextBox1.Text = ""
Then
MsgBox("please entry your number")
End If
If TextBox2.Text = ""
Then
MsgBox("please entry your name")
End If
If TextBox3.Text = ""
Then
MsgBox("please entry your address")
Else
Timer1.Enabled = True
End If
End Sub
Private Sub
Button8_Click(sender As System.Object, e As
System.EventArgs) Handles
Button8.Click
If Timer1.Enabled = True
Then
Timer1.Enabled = False
End If
If RadioButton1.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = TextBox1.Text - RadioButton1.Text
Button1.Visible = True
Button2.Visible = True
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
Button8.Visible = False
TextBox1.Text = "50000"
TextBox2.Text = ""
TextBox3.Text = ""
MsgBox("SORRY,YOU MUST TRY AGAIN!")
End If
End If
If RadioButton2.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = TextBox1.Text - RadioButton2.Text
Button1.Visible = True
Button2.Visible = True
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
Button8.Visible = False
TextBox1.Text = "50000"
TextBox2.Text = ""
TextBox3.Text = ""
MsgBox("SORRY,YOU MUST TRY AGAIN!")
End If
End If
If RadioButton3.Checked Then
If Label5.Text = Label6.Text Or
Label6.Text = Label7.Text Or Label5.Text =
Label7.Text Then
TextBox1.Text = TextBox1.Text * 2
MsgBox("CONGRATULATION! YOU ARE THE
WINNER! :D")
Else
TextBox1.Text = TextBox1.Text - RadioButton3.Text
Button1.Visible = True
Button2.Visible = True
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
Button8.Visible = False
TextBox1.Text = "50000"
TextBox2.Text = ""
TextBox3.Text = ""
MsgBox("SORRY,YOU MUST TRY AGAIN!")
End If
End If
End Sub
End Class
Selesai....
1
gann...boleh tolong gambar nya d munculin??
BalasHapuslagi perlu banget nihh...
makasih sebelumnya....
untuk aplikasi perpus nya juga gan??
BalasHapus