0% found this document useful (0 votes)
57 views

1) Code For Form 1

The document contains code for 5 forms (Form1-Form4 and a pause form) that make up a game. Form1 contains buttons to navigate between forms. Form2 contains the game logic to move objects and track score. It also saves high scores to a database. Form3 allows starting the game. The pause form pauses the game. The credit form returns to the main menu.

Uploaded by

Nabin Majhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

1) Code For Form 1

The document contains code for 5 forms (Form1-Form4 and a pause form) that make up a game. Form1 contains buttons to navigate between forms. Form2 contains the game logic to move objects and track score. It also saves high scores to a database. Form3 allows starting the game. The pause form pauses the game. The credit form returns to the main menu.

Uploaded by

Nabin Majhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1) Code for form 1

2) Public Class Form1


3) Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
4) Me.Hide()
5) Form3.Show()
6) End Sub
7)
8) Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
9) Application.Exit()
10)
11) End Sub
12)
13) Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
14) Me.Hide()
15) credit.Show()
16) End Sub
17)
18) Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
19) Form4.Show()
20) End Sub
21) End Class

Code for form 2

Imports System.Data.SqlClient
Public Class Form2
Dim mycon As SqlConnection
Dim mycom As SqlCommand
Public score As Integer
Dim w As Integer = 6
Dim x As Integer = 3
Dim y As Integer = 7
Dim z As Integer = 5
Dim S As Integer
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
Timer1.Start()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick


PictureBox1.Top -= w
PictureBox5.Top -= x
PictureBox3.Top -= y
PictureBox2.Top -= z
Label1.Text = score

S = Label1.Text
If PictureBox1.Location.Y < 25 Or PictureBox5.Location.Y < 25 Or
PictureBox2.Location.Y < 25 Or PictureBox3.Location.Y < 25 Then
Me.Dispose()
MsgBox("GAME OVER!")
Form1.Show()

Try
mycon = New SqlConnection("Data Source=DESKTOP-M8QL80I;Initial
Catalog=antgame;Integrated Security=True")
mycom = New SqlCommand("insert into highscore values('" +
Form3.TextBox1.Text + "','" + S + "')", mycon)
mycon.Open()
mycom.ExecuteNonQuery()
mycon.Close()
Catch ex As Exception
MsgBox(ex.Message())
End Try

End If

If (score = 10) Then


x = x + 1
y = y + 1
z = z + 1
w = w + 1
End If
If (score = 20) Then
x = x + 1.15
y = y + 1.15
z = z + 1.15
w = w + 1.15
End If
If (score = 30) Then
x = x + 1.3
y = y + 1.3
z = z + 1.3
w = w + 1.3
End If
If (score = 40) Then
x = x + 1.45
y = y + 1.45
z = z + 1.45
w = w + 1.45
End If
End Sub

Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles


PictureBox5.Click
score = score + 1
Label1.Text = score
PictureBox5.Top = 550
End Sub
Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles
PictureBox3.Click
score = score + 1
Label1.Text = score
PictureBox3.Top = 530
End Sub
Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles
PictureBox2.Click
score = score + 1
Label1.Text = score
PictureBox2.Top = 500
End Sub

Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles


PictureBox1.Click
score = score + 1
Label1.Text = score
PictureBox1.Top = 700
End Sub

Private Sub PictureBox4_Click(sender As Object, e As EventArgs)


Application.Exit()

End Sub

Private Sub PictureBox6_Click(sender As Object, e As EventArgs) Handles


PictureBox6.Click
pause.Show()
End Sub
End Class

Code for form 3

Public Class Form3


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Hide()
Form2.Show()
End Sub
End Class

Code for form 4

Public Class pause


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Application.Exit()
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


Me.Hide()
Form2.Show()
End Sub
End Class

Coed for credit

Public Class credit


Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles
PictureBox1.Click
Form1.Show()
End Sub
End Class

You might also like