Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 107

VISUAL BASICS

LABORATORY
CAT 2

SUBMITTED BY:
KRSHNA PRIYA .R
19 31 018
2nd YEAR MSC SS
INDEX

S.no Project name Interface

1 Payment gateway Vb.net and MYSQL

2 EB bill calculation Vb.net

3 Car simulation Vb.net

4 Hospital token Vb.net and MYSQL


generation

5 Chess game Vb.net


DOCUMENTATION

1. Simulation of Payment Gateway Processing like BillDesk, Techprocess etc.

PROBLEM STATEMENT:
This problem is to create a VB.NET project to simulate the process
of payment gateway like Bill Desk, Tech Process, etc to know how the
bill desk or online payment gateway works.

PROBLEM DEFINITION:
To make payment through payment gateway ,the payee must
obtain a bank card from an issuing bank and when making a purchase,
he/she must provide bank card information. Here the payment gateway
process is simulated using VB.net to save the details of the card user
for transactions. This problem is mainly to simulate the online payment
gateway process and to transfer money from one bank account to another
bank account. Where, the bill desk is the intermediate between the bank
and the user.

PROBLEM ABSTRACT:
This problem is mainly developed to visualize the process of online
payment gateways like
● getting the user details from the application,
● pass them to cross verify with the database,
● Checks amount balance and transfers it to another account
● Finally it makes a transaction through online.
Online payment system can let people who purchase something and make
payments using their credit card. The payment gateway process implemented
using VB.net accepts the details such as Card user name, Card number, CVV
number and Expiry Date for transactions. The collected details are saved in the
database of the payment gateway and these details are verified with the bank
and the transaction is completed at once the details are verified.

PROJECT OBJECTIVE:
The Main objective of this problem is to get a clear idea on how the online
payment gateway application works as an intermediate between the user and
the bank server, and how it verifies the data sent by the user with the bank
server.

PROJECT SCOPE:
This project focus on the awareness and the usage of
electronic payment to the users. To support the users to make use of
electronic mode of payments.To make is easy to use the application for
future transactions.

PROJECT DESCRIPTION:
The simulation of payment gateway is implemented using VB.net. The
payment gateway process simulation uses database to store the card user
details to be verified.
This project is mainly to make use or get to usage of online or
electronic mode of money transactions, and to know how the online
payment gateways like Bill desk, Tech Process works.
SYSTEM DESIGN:
ER DIAGRAM:

USER INTERFACE DESIGN:


IMPLEMENTATION:
This project is implemented using VB (Visual Basic) Application
and it
is implemented by using .NET Framework and The Storage
Database used
here is Microsoft SQL Server.
TESTING:
Inputs are Card No , Name on card , CVV no , Expiry date , Payee
name, Payee account no and amount

Inputs
Test Case : 1234 1223 1233 2344
Krshna priya .R
899
12/10/2025
Oviya
1233 1223 1222 1233
23400

Output : Amount paid successfully.

SCREENSHOTS:
CONCLUSION:
This simulation of payment gateway process lets us learn the working of
the process involved in the payment transactions.

FUTURE ENHANCEMENTS:
This code can be further enhanced to create a separate login page and
registration page for the users.This code can also be further enhanced to
verify the OTP sent to the mobile to complete the transaction.
SOURCE CODE:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles PAYMENT.Click
Dim con As SqlConnection = New SqlConnection("Data
Source=DESKTOP-94C9AQ8\SQLEXPRESS;Initial Catalog=pay;Integrated
Security=True")
Dim cmd As SqlCommand = New SqlCommand("INSERT INTO [dbo].
[pay]
([Name on card]
,[Card number]
,[CVV number]
,[Expiry date]
,[Payee Name]
,[Payee Account No]
,[Amount])

VALUES
('" + namecard.Text + "', '" + cardno.Text + "', '" +
cvvno.Text + "', '" + DateTimePicker1.Text + "', '" +
payeename.Text + "', '" + accno.Text + "', '" + amount.Text + "')",
con)

con.Open()
cmd.ExecuteNonQuery()
MsgBox("Payment is paid successfully.")

con.Close()
End Sub
End Class

DATA DICTIONARY:

Column Data Type Description


Varchar(20)
Name Name on the card

Card Number Numeric(18,0) ATM card number


CVV int 3 digit unique number
Expiry date date Expiry date of the card
Payee Name Varchar(20) Payee Name

Payee Account Numeric(18,0) Payee Account Number


Number
Amount int Amount for transaction

2. Simulation of Car driving learning systems.

PROBLEM STATEMENT:
Simulation of car driving learning process. This problem is to create a
VB.NET project to simulate a driving Car to test the Driving skill of the user.

PROBLEM DEFINITION:
To design a VB.net application to simulate the car driving learning system ,such as
turning the car and moving without hitting any obstacles. This project is mainly used to test
the driving skill of the user.It will help the user to provide a better understanding about
driving a Car.

PROBLEM ABSTRACT:
This VB.net application is designed to simulate the car driving learning system .The map
contains road turnings and obstacles. The player must complete the map without hitting
any obstacles to complete. If hit on any obstacles the player must replay the game. Provide
keys to move the car.Provide obstacles to help the user to dodge obstacles in a perfect
way.Provide a score to help the user to calculate their skill.

PROJECT OBJECTIVE:
To let the user simulate the car driving learning. The objective of this project is to help the
users to test their driving skill and to know their current level of driving skill.This projects
provides the user to operate a car in a 2D view.Buttons are used to operate the car in a best
way.To Help the users to learn driving in a most easiest way.
PROJECT SCOPE:
The user can learn the car driving through simulation if future enhancements are added
with proper hardware.

PROJECT DESCRIPTION:
The application is developed using VB.net Windows Forms application. The car driving
learning is simulated using simple and basic controls such as the arrow keys for moving the
car. This project is used to make use of the electronic systems to learn driving in aeasier
way.To get a better idea about driving a car and gives a better experience beforedriving a
car on road.

USER INTERFACE DESIGN:


up arrow key - to move the car forward.
Down arrow key - to stop the car.
Right button - to move the car right.
Left button- to move the car left.
Straight button and Reverse button –- to move the car straight and reverse.
Total(10 Pictureboxes)
1 for player car.

IMPLEMENTATION:
TESTING:
This project is tested by moving the car in varies directions and checked whether the
obstacle cars are correctly placed or not.

SCREENSHOTS:
CONCLUSION:
This application can be very useful to beginners to learn car driving as this
involves only virtual driving.

FUTURE ENHANCEMENTS:
This can be enhanced by adding various levels of different maps and difficulty. Also
physical hardware such as steering wheel can be handed to control the car.

SOURCE CODE:
Public Class Form1
Dim currDirection As String = "Up"
Private Sub moveleft_Tick(sender As Object, e As EventArgs) Handles
moveleft.Tick
If moveleft.Enabled.ToString() = True Then
caranimation.Left = caranimation.Left - 5
End If
End Sub
Private Sub moveup_Tick(sender As Object, e As EventArgs) Handles
moveup.Tick
If moveup.Enabled.ToString() = True Then
caranimation.Top = caranimation.Top - 5
End If
End Sub
Private Sub movedown_Tick(sender As Object, e As EventArgs) Handles
movedown.Tick
If movedown.Enabled.ToString() = True Then
caranimation.Top = caranimation.Top + 5
End If
End Sub

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


moveright.Tick
If moveright.Enabled.ToString() = True Then
caranimation.Left = caranimation.Left + 5
End If
End Sub

Private Sub LEFT_Click(sender As Object, e As EventArgs) Handles LEFT.Click


Dim bmp As Bitmap = New Bitmap(caranimation.Image)
If currDirection = "Up" Then
moveup.Stop()
bmp.RotateFlip(RotateFlipType.Rotate270FlipNone)
ElseIf currDirection = "Right" Then
moveright.Stop()
bmp.RotateFlip(RotateFlipType.Rotate180FlipNone)
ElseIf currDirection = "Down" Then
movedown.Stop()
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone)
End If
caranimation.Image = bmp
currDirection = "Left"
moveleft.Start()
End Sub

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


Right.Click
Dim bmp As Bitmap = New Bitmap(caranimation.Image)
If currDirection = "Up" Then
moveup.Stop()
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone)
ElseIf currDirection = "Left" Then
moveleft.Stop()
bmp.RotateFlip(RotateFlipType.Rotate180FlipNone)
ElseIf currDirection = "Down" Then
movedown.Stop()
bmp.RotateFlip(RotateFlipType.Rotate270FlipNone)
End If
caranimation.Image = bmp
currDirection = "Right"
moveright.Start()
End Sub

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


Straight.Click
Dim bmp As Bitmap = New Bitmap(caranimation.Image)
If currDirection = "Left" Then
moveleft.Stop()
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone)
ElseIf currDirection = "Right" Then
moveright.Stop()
bmp.RotateFlip(RotateFlipType.Rotate270FlipNone)
ElseIf currDirection = "Down" Then
movedown.Stop()
bmp.RotateFlip(RotateFlipType.Rotate180FlipNone)
End If

caranimation.Image = bmp
currDirection = "Up"
moveup.Start()
End Sub

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


Reverse.Click

Dim bmp As Bitmap = New Bitmap(caranimation.Image)


If currDirection = "Up" Then
moveup.Stop()
bmp.RotateFlip(RotateFlipType.Rotate180FlipNone)
ElseIf currDirection = "Left" Then
moveleft.Stop()
bmp.RotateFlip(RotateFlipType.Rotate270FlipNone)
ElseIf currDirection = "Right" Then
moveright.Stop()
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone)
End If
caranimation.Image = bmp
currDirection = "Down"
movedown.Start()
End Sub

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


PictureBox71.Click

End Sub
End Class
3. Web application for the electricity bill calculator with recent tariff
plans.

PROBLEM STATEMENT:
This problem is to create a VB .NET project to simulate the process of
eb bill calculation with different tarriff type.

PROBLEM DEFINITION:
This problem is mainly to simulate the electricity bill of any domestic or
commercial(tariff).To generate the electricity bill for the user based on the
details specified. Electricity bill is generated based on Domestic , Industrial
and comerical purpose. Inorder to avoid errors , formula is used so that
manual errors does not occur.

PROBLEM ABSTRACT:
The application contains fields namely Consumer name, consumer no,
tariff check, tariff type, previous readings and current readings. The user must
fill these details and based on the tariff, the electricity bill is generated.
PROJECT OBJECTIVE:
To generate the EB bill based on the fields specified. Based on
previous reading and current reading and also based on Industrial ,
Domestic and Commercial purpose the bill is calculated.

PROJECT SCOPE:
The EB bill of user can be calculated easily.  This project focus on the awareness and
the usage of unit consumed in (domestic or commercial)To support the users to make use
of how to calculate eb bill.

PROJECT DESCRIPTION:
The application to generate the EB bill is designed using VB.net Windows
Forms application. The user has to select the tariff check ,enter the previous
and current readings and click on the calculate button to generate the bill.

USER INTERFACE DESIGN:


IMPLEMENTATION:

TESTING:
Inputs are Name , Consumer No , Tariff Type, Billing cycle , Previous
units and Current units.

Input:
Test Case : Krshna priya
12345332345432
Domestic
Monthly
1200
2200

Output : Unit consumed is 1000


Amount is 5080

Input:
Test Case : Krshna priya
12345332345432
Commercial
Monthly
1200
2200

Output : Unit consumed is 1000


Amount is 8050
Input:
Test Case : Krshna priya
12345332345432
Indusrial
Monthly
1200
2200

Output : Unit consumed is 1000


Amount is 6350

SCREENSHOTS:
CONCLUSION:
This web application can be used to calculate the EB bill for domestic, commercial, actual
places of public worship and power looms based on their recent tariff. Finally, this project is
developed and it is tested and the application is ready to use by the users.

FUTURE ENHANCEMENTS:
This can be further enhanced to pay the electricity bill and create a
database to store the user’s login details.

SOURCE CODE:
LOGIN PAGE:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)

Handles Button1.Click
If TextBox1.Text = "" And TextBox2.Text = "" Then
MsgBox("Username or Password cannot be blank.")
ElseIf TextBox1.Text = "krshnapriya" And TextBox2.Text =
"priya" Then
MsgBox("Login Successful.")
Me.Hide()
Form2.Show()
Else
MsgBox("Incorrect Username or Password.")

End If
End Sub
End Class

EB CALACULATOR:
Public Class Form2
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs)
Handles RadioButton1.CheckedChanged
Dim pu As Integer
Dim cu As Integer
Dim uc As Integer
Dim bill As Double
pu = putxt.Text
cu = cutxt.Text

uc = cu - pu

uclbl.Text = uc

If (Int(uc <= 100)) Then


bill = uc * 0

ElseIf (Int(uc <= 200)) Then


bill = 100 * 0 + (uc - 100) * 1.5 + 20

ElseIf (Int(uc <= 500)) Then


bill = (100 * 0) + (100 * 2) + (uc - 200) * 3 + 30

Else
bill = (100 * 0) + (100 * 3.5) + (300 * 4.6) + (uc - 500) * 6.6 +
50
End If

billlbl.Text = CStr(bill)
End Sub

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


Handles RadioButton2.CheckedChanged
Dim pu As Integer
Dim cu As Integer
Dim uc As Integer
Dim bill As Double

pu = putxt.Text
cu = cutxt.Text

uc = cu - pu

uclbl.Text = uc
If (Int(uc <= 100)) Then
bill = uc * 5

Else
bill = uc * 8.05
End If

billlbl.Text = CStr(bill)

End Sub

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


Handles RadioButton3.CheckedChanged
Dim pu As Integer
Dim cu As Integer
Dim uc As Integer
Dim bill As Double

pu = putxt.Text
cu = cutxt.Text

uc = cu - pu

uclbl.Text = uc

bill = uc * 6.35

billlbl.Text = CStr(bill)
End Sub

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

End Sub
End Class

4. Web application: Token Generation System for clinic.

PROBLEM STATEMENT:
Token generation for clinic. If we do manually there will be lot of
paper works and have greater chances for generation of errors. So,
inorder to overcome that we should develop a web application for
token generation system for a clinic.

PROBLEM DEFINITION:
The token generation process can be simulated by using VB.net saving
the patient details using a database and generation token based on patient’s
convenient date and time. This problem is mainly to create a token generating
application for the patients who comes to the hospital for doctor consultation.
This application generates token based on the patients. Those who comes first
for consultation gets the first token and then followed by the others.
PROBLEM ABSTRACT:
The tokenno is generated by filling some details of the patient.
This includes Patient’s name , Date of Appointment , Age , Phone no and
Symptoms. Other health details should also be included. By clicking on
Generate tokenno button token number is generated.

PROJECT OBJECTIVE:
To generate the tokenno for the patient based on the health condition. The
main goal or the objective of this project is to create an application for the hospital to make
appointment with the doctors in a token order, where the application helps in generating
the token for the patients.

PROJECT SCOPE:
This can be used to study the token generation process in a better way.
This application creates the patient’s record and store them in a data base.Then
it generates token, when the patient confirms their appointment. This token
generated is ordered and unique for an individual patient. If the patient wish
not to come to the hospital, they can also cancel their token.

PROJECT DESCRIPTION:
The token generation process can be implemented using VB.net
which will be useful for the patient. It also uses the database to
store patient’s detail so that it can be retrieved easily.

SYSTEM DESIGN:
USER INTERFACE DESIGN:
This Application is built using VB .NET application. It has
4 Textboxes,
3 Radio Buttons,
2 Buttons,
1 Data Grid View,
1 Date Time Selector.
IMPLEMENTATION:
TESTING:
Inputs : 30 October 2020
Krshnapriya
Female
19
9023443342
Cold ,Cough

Output :
The token no is 4
SCREENSHOTS:
CONCLUSION:
The token generation system helps us to know the
steps involved in booking the appointment through web
application.

FUTURE ENHANCEMENTS:
This can be further enhanced in such a way that there
will be a separate login page for both the users and admin.
When the patient book their appointment then message
should be sent to the doctor so that doctor know patients.

SOURCE CODE:
LOGIN FORM:
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
Close()
End Sub

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


Button1.Click
If TextBox1.Text = "krshnapriya" And TextBox2.Text = "priya" Then
Timer1.Start()
Else
MsgBox("Incorrect Username or Password", MsgBoxStyle.Critical,
"Error")
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(2)
If ProgressBar1.Value = ProgressBar1.Maximum Then
Me.Hide()
Form2.Show()
End If
End Sub
End Class

TOKEN GENERATION:
Imports System.Data.SqlClient

Public Class Form2


Dim connection As New SqlConnection("Data Source=DESKTOP-
94C9AQ8\SQLEXPRESS;Initial Catalog=hospital;Integrated
Security=True")

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


Handles Button1.Click
autoid()
Dim cmd As SqlCommand = New SqlCommand("INSERT INTO [dbo].
[hospital]
([Tokenno]
,[Date of Appointment]
,[Name of Patient]
,[Age]
,[Phone Number]
,[Symptoms])
VALUES('" & token.Text & "','" & dat.Text & "','" &
patientname.Text & "','" & age.Text & "' ,'" & phoneno.Text & "','"
& disease.Text & "')", connection)
connection.Open()
cmd.ExecuteNonQuery()
connection.Close()
MsgBox("Doctor appointment is scheduled and Token no is
generated.")
End Sub

Public Sub ExecuteQuery(query As String)


Dim command As New SqlCommand(query, connection)
connection.Open()
command.ExecuteNonQuery()
connection.Close()
End Sub
Public Sub autoid()
Dim con As New SqlConnection
Dim unused As New SqlCommand
Dim num As Integer
con.ConnectionString = "Data Source=DESKTOP-
94C9AQ8\SQLEXPRESS;Initial Catalog=hospital;Integrated
Security=True"
con.Open()
Dim cmd As SqlCommand = New SqlCommand("SELECT max(Tokenno)
from hospital", con)
cmd.ExecuteNonQuery()

If IsDBNull(cmd.ExecuteScalar) Then
num = 1
token.Text = num

Else
num = cmd.ExecuteScalar + 1
token.Text = num
End If
con.Close()
End Sub
End Class

DATA DICTIONARY:
Column Data Type Description
Token No Int Primary key

Name Varchar(20) Name of the patient

Date of appointment date Date of appointment

Age Int Age of patient


Phone number Numeric(10) Phone no of the
patient

Symptoms varchar(50) Symptoms of the patient

5. Game application: chess

PROBLEM STATEMENT:
To create a chess game simulation using vb.net that follow the rules of the chess game.

PROBLEM DEFINITION:
To design a VB.net application to simulate a chess game like coins
moving based on the game rules , setting a timer and Loosing or
winning based on the Checkmate.

This problem is mainly developed to simulate a chess game mequal to a real chess game
and the game simulation follows the chess rules like:
Chess moves
• King can move exactly one square horizontally, vertically, or diagonally. At most once in
every game, each king is allowed to make a special move, known as castling.
• Queen can move any number of vacant squares diagonally, horizontally,or vertically.
• Rook can move any number of vacant squares vertically or horizontally.It also is moved
while castling.
• Bishop can move any number of vacant squares in any diagonal direction.
• Knight can move one square along any rank or file and then at an angle. The knight´s
movement can also be viewed as an “L” or “7″ laid out atany horizontal or vertical angle.
• Pawns can move forward one square, if that square is unoccupied. If ithas not yet moved,
the pawn has the option of moving two squares forward provided both squares in front of
the pawn are unoccupied. A pawn cannot move backward. Pawns are the only pieces that
capture differently from how they move. They can capture an enemy piece on either of the
two spaces adjacent to the space in front of them (i.e., the two squares diagonally in
frontof them) but cannot move to these spaces if they are vacant. The pawn is alsoinvolved
in the two special moves en passant and promotion.

PROBLEM ABSTRACT:
The application contains the name of the players. Game mode is also
available. By clicking on the start game button all the coins gets
displayed. The chess board is created by using 64 picture boxes and the
coins the inserting the respective images for both the white and black
coins. Show the player the available moves, Automatically check for check for
king. Automatically check for check mate for kingPrinting message box
showing the winner. Give-up button if the players want to end the game in
between.

PROJECT OBJECTIVE:
To simulate the chess game application so that the players can Start a
new game and to quit the game. The Main objective of this problem is to get a clear idea
on how the chess game application works as in pc mode rather than a real game. In a real
chess-game the players check’s manually for the available moves but in pc mode the
application shows the available moves and also check and check mate.

PROJECT SCOPE:
This can be used to study the working of a chess game. The rules of the
chess game will become more clear.This project (Chess game application)
focus on the awareness and theusage of chess game in an online mode.The
beginners can learn chess through this application as this application shows the
available moves and the check and check mate.To make it easy for players to
play in this application.

PROJECT DESCRIPTION:
The simulation of chess game is implemented using VB.net
Windows form application. The chess game is simulated using simple
moves for the respective black and white coins. Each coin is designed
to some restrictions based on the rules of each coin.

USER INTERFACE DESIGN:


3 – Buttons
1 – Button for new game button
2 – Buttons for give up for the two players
65 – Image boxes
1 – Image Box for board image
64 – Image Box for the boxes in the chess board
2 – Labels
2 – labels to display the player’s name
IMPLEMENTATION:
The above-mentioned buttons and picture boxes are placed in the userInterface Form1.vb
.In form1 code is used to change pictures and background in pictureBox. Used to access the
pieces class and check for available moves make movements using the function available in
the piece classesKing /queen/pawn/bishop/knight/rook class .In each of these classes
similar functions like possible_move (to find possible moves) check_king(to check ‘check’ of
both black king) are defined which is called by the game_form to find the next possible
move and make movements and to declare check.
TESTING:
Input : When the coins are moved according to the respective black and
white moves then the finally Checkmate will be the output.

SCREENSHOTS:
CONCLUSION:
This application will be useful to learn the chess
game.

FUTURE ENHANCEMENTS:
Leader Board option which includes the list of players based on their
scores. Top 10 scorers should be displayed.
Setting the timer for both the players. When the players run out of time
then he/she looses the game.
There should be an option called player to computer where the computer
gets chance and then the other player gets the other chance and so on.

SOURCE CODE:
FORM1.VB
Public Class Form1

Public pb(7, 7) As PictureBox


Public w_king As king
Public w_queen As queen
Public w_bishop(1) As bishop
Public w_knight(1) As knight
Public w_rook(1) As rook
Public w_pawn(7) As pawn
Public b_king As king
Public b_queen As queen
Public b_bishop(1) As bishop
Public b_knight(1) As knight
Public b_rook(1) As rook
Public b_pawn(7) As pawn

Public ga As game
Public x, y, sel_x, sel_y As Integer
Public selected As Boolean = False
Public sel_piece As String = Nothing
Private Sub Newgame_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Newgame.Click

pb = New PictureBox(7, 7) {{Me.p00, Me.p01, Me.p02, Me.p03, Me.p04, Me.p05,


Me.p06, Me.p07},
{Me.p10, Me.p11, Me.p12, Me.p13, Me.p14, Me.p15, Me.p16,
Me.p17},
{Me.p20, Me.p21, Me.p22, Me.p23, Me.p24, Me.p25, Me.p26,
Me.p27},
{Me.p30, Me.p31, Me.p32, Me.p33, Me.p34, Me.p35, Me.p36,
Me.p37},
{Me.p40, Me.p41, Me.p42, Me.p43, Me.p44, Me.p45, Me.p46,
Me.p47},
{Me.p50, Me.p51, Me.p52, Me.p53, Me.p54, Me.p55, Me.p56,
Me.p57},
{Me.p60, Me.p61, Me.p62, Me.p63, Me.p64, Me.p65, Me.p66,
Me.p67},
{Me.p70, Me.p71, Me.p72, Me.p73, Me.p74, Me.p75, Me.p76,
Me.p77}}

all_objects()
ga.re_can_move()
ga.show()
ga.re_back()
ga.fill_chk_for_black()
ga.fill_chk_for_white()

End Sub

Public Sub all_objects()


w_king = New king(0, 4, 1)
w_queen = New queen(0, 3, 2)
w_bishop(0) = New bishop(0, 2, 3)
w_bishop(1) = New bishop(0, 5, 3)
w_knight(0) = New knight(0, 1, 4)
w_knight(1) = New knight(0, 6, 4)
w_rook(0) = New rook(0, 0, 5)
w_rook(1) = New rook(0, 7, 5)
w_pawn(0) = New pawn(1, 0, 6)
w_pawn(1) = New pawn(1, 1, 6)
w_pawn(2) = New pawn(1, 2, 6)
w_pawn(3) = New pawn(1, 3, 6)
w_pawn(4) = New pawn(1, 4, 6)
w_pawn(5) = New pawn(1, 5, 6)
w_pawn(6) = New pawn(1, 6, 6)
w_pawn(7) = New pawn(1, 7, 6)

b_king = New king(7, 4, -1)


b_queen = New queen(7, 3, -2)
b_bishop(0) = New bishop(7, 2, -3)
b_bishop(1) = New bishop(7, 5, -3)
b_knight(0) = New knight(7, 1, -4)
b_knight(1) = New knight(7, 6, -4)
b_rook(0) = New rook(7, 0, -5)
b_rook(1) = New rook(7, 7, -5)
b_pawn(0) = New pawn(6, 0, -6)
b_pawn(1) = New pawn(6, 1, -6)
b_pawn(2) = New pawn(6, 2, -6)
b_pawn(3) = New pawn(6, 3, -6)
b_pawn(4) = New pawn(6, 4, -6)
b_pawn(5) = New pawn(6, 5, -6)
b_pawn(6) = New pawn(6, 6, -6)
b_pawn(7) = New pawn(6, 7, -6)

ga = New game()

End Sub

Private Sub p00_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p00.Click
ga.re_back()
x=0
y=0
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub
Private Sub p01_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p01.Click
ga.re_back()
x=0
y=1
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub
Private Sub p02_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p02.Click
ga.re_back()
x=0
y=2
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub
Private Sub p03_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p03.Click
ga.re_back()
x=0
y=3
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub
Private Sub p04_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p04.Click
ga.re_back()
x=0
y=4
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub
Private Sub p05_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p05.Click
ga.re_back()
x=0
y=5
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub
Private Sub p06_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p06.Click
ga.re_back()
x=0
y=6
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub
Private Sub p07_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p07.Click
ga.re_back()
x=0
y=7
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub

Private Sub p10_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p10.Click
ga.re_back()
x=1
y=0
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p11_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p11.Click
ga.re_back()
x=1
y=1
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p12_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p12.Click
ga.re_back()
x=1
y=2
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p13_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p13.Click
ga.re_back()
x=1
y=3
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p14_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p14.Click
ga.re_back()
x=1
y=4
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p15_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p15.Click
ga.re_back()
x=1
y=5
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p16_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p16.Click
ga.re_back()
x=1
y=6
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p17_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p17.Click
ga.re_back()
x=1
y=7
If selected <> True Then

sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub

Private Sub p20_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p20.Click
ga.re_back()
x=2
y=0
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If

End Sub
Private Sub p21_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p21.Click
ga.re_back()
x=2
y=1
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p22_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p22.Click
ga.re_back()
x=2
y=2
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p23_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p23.Click
ga.re_back()
x=2
y=3
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p24_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p24.Click
ga.re_back()
x=2
y=4
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p25_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p25.Click
ga.re_back()
x=2
y=5
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p26_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p26.Click
ga.re_back()
x=2
y=6
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p27_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p27.Click
ga.re_back()
x=2
y=7
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub

Private Sub p30_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p30.Click
ga.re_back()
x=3
y=0
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p31_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p31.Click
ga.re_back()
x=3
y=1

If selected <> True Then


ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()

End If
End Sub
Private Sub p32_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p32.Click
ga.re_back()
x=3
y=2
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p33_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p33.Click
ga.re_back()
x=3
y=3
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p34_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p34.Click
ga.re_back()
x=3
y=4
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p35_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p35.Click
ga.re_back()
x=3
y=5
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p36_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p36.Click
ga.re_back()
x=3
y=6
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p37_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p37.Click
ga.re_back()
x=3
y=7
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub

Private Sub p40_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p40.Click
ga.re_back()
x=4
y=0
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p41_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p41.Click
ga.re_back()
x=4
y=1
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p42_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p42.Click
ga.re_back()
x=4
y=2
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p43_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p43.Click
ga.re_back()
x=4
y=3
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p44_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p44.Click
ga.re_back()
x=4
y=4
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p45_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p45.Click
ga.re_back()
x=4
y=5
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p46_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p46.Click
ga.re_back()
x=4
y=6
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p47_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p47.Click
ga.re_back()
x=4
y=7
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub

Private Sub p50_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p50.Click
ga.re_back()
x=5
y=0
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p51_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p51.Click
ga.re_back()
x=5
y=1
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p52_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p52.Click
ga.re_back()
x=5
y=2
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p53_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p53.Click
ga.re_back()
x=5
y=3
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p54_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p54.Click
ga.re_back()
x=5
y=4
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p55_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p55.Click
ga.re_back()
x=5
y=5
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p56_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p56.Click
ga.re_back()
x=5
y=6
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p57_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p57.Click
ga.re_back()
x=5
y=7
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub

Private Sub p60_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p60.Click
ga.re_back()
x=6
y=0
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p61_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p61.Click
ga.re_back()
x=6
y=1
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p62_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p62.Click
ga.re_back()
x=6
y=2
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p63_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p63.Click
ga.re_back()
x=6
y=3
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p64_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p64.Click
ga.re_back()
x=6
y=4
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p65_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p65.Click
ga.re_back()
x=6
y=5
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p66_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p66.Click
ga.re_back()
x=6
y=6
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p67_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p67.Click
ga.re_back()
x=6
y=7
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub

Private Sub p70_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p70.Click
ga.re_back()
x=7
y=0
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p71_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p71.Click
ga.re_back()
x=7
y=1
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p72_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p72.Click
ga.re_back()
x=7
y=2
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p73_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p73.Click
ga.re_back()
x=7
y=3
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p74_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p74.Click
ga.re_back()
x=7
y=4
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p75_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p75.Click
ga.re_back()
x=7
y=5
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub
Private Sub MaskedTextBox1_MaskInputRejected(sender As Object, e As
MaskInputRejectedEventArgs) Handles MaskedTextBox1.MaskInputRejected

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Me.Close()
End Sub

Private Sub p76_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles p76.Click
ga.re_back()
x=7
y=6
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub
Private Sub p77_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles p77.Click
ga.re_back()
x=7
y=7
If selected <> True Then
ga.re_can_move()
sel_piece = ga.selection(x, y)
sel_x = x
sel_y = y
selected = True
Else
If ga.can_move(x, y) = True Then
ga.mov(sel_piece, x, y, sel_x, sel_y)
End If
selected = False
ga.show()
End If
End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)

End Sub
End Class

GAME.VB
Public Class game
Public board(7, 7) As Integer
Public can_move(7, 7) As Boolean
Public check_for_white(7, 7) As Boolean
Public check_for_black(7, 7) As Boolean
Public game_flag As Boolean = True
Public player As Integer = 1
Public b_in_danger As Boolean = False
Public w_in_danger As Boolean = False
Public Sub New()

board = {{5, 4, 3, 2, 1, 3, 4, 5},


{6, 6, 6, 6, 6, 6, 6, 6},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{-6, -6, -6, -6, -6, -6, -6, -6},
{-5, -4, -3, -2, -1, -3, -4, -5}} ''

re_chk_black()
re_chk_white()

End Sub
Public Sub chk_winner(ByVal selected, ByVal x, ByVal y)
show()

If Form1.b_king.x_pos = x And Form1.b_king.y_pos = y And selected <> "b_king"


Then
game_flag = False
End If
If game_flag = False Then
MsgBox("CHECKMATE!!!")
MsgBox("PLAYER 1 WINS THE GAME.")
MsgBox("Do you want to continue? Press New Game button to continue.")
Exit Sub
End If

If Form1.w_king.x_pos = x And Form1.w_king.y_pos = y And selected <>


"w_king" Then
game_flag = False
End If
If game_flag = False Then
MsgBox("CHECKMATE!!!")
MsgBox("PLAYER 2 WINS THE GAME.")
MsgBox("Do you want to continue? Press New Game button to continue.")
Exit Sub
End If
End Sub

Public Sub show()

For i As Integer = 0 To 7
For j As Integer = 0 To 7

Select Case board(i, j)


Case 1
Form1.pb(i, j).Image = My.Resources.wKing
Case 2
Form1.pb(i, j).Image = My.Resources.wQueen
Case 3
Form1.pb(i, j).Image = My.Resources.Wbishop
Case 4
Form1.pb(i, j).Image = My.Resources.wKnight
Case 5
Form1.pb(i, j).Image = My.Resources.wRook
Case 6
Form1.pb(i, j).Image = My.Resources.wPawn
Case -1
Form1.pb(i, j).Image = My.Resources.bKing
Case -2
Form1.pb(i, j).Image = My.Resources.bQueen
Case -3
Form1.pb(i, j).Image = My.Resources.bBishop
Case -4
Form1.pb(i, j).Image = My.Resources.bKnight
Case -5
Form1.pb(i, j).Image = My.Resources.bRook
Case -6
Form1.pb(i, j).Image = My.Resources.bPawn

Case Else
Form1.pb(i, j).Image = Nothing

End Select
show_chk()
Next
Next
End Sub

Public Function selection(ByVal x, ByVal y) As String


If game_flag = True Then
If board(x, y) <> 0 Then
Form1.pb(x, y).BackgroundImage = My.Resources.selection
End If
Select Case board(x, y)
Case 1
If player = 1 Then
show_possible_move(Form1.w_king.poss_mov())
Return "w_king"
End If
Case 2
If player = 1 Then
show_possible_move(Form1.w_queen.poss_mov())
Return "w_queen"
End If
Case 3
If player = 1 Then
For i As Integer = 0 To 1
If Form1.w_bishop(i).ret_x = x And Form1.w_bishop(i).ret_y = y Then
show_possible_move(Form1.w_bishop(i).poss_mov())
End If
Next
Return "w_bishop"
End If
Case 4
If player = 1 Then
For i As Integer = 0 To 1
If Form1.w_knight(i).ret_x = x And Form1.w_knight(i).ret_y = y Then
show_possible_move(Form1.w_knight(i).poss_mov())
End If
Next
Return "w_knight"
End If
Case 5
If player = 1 Then
For i As Integer = 0 To 1
If Form1.w_rook(i).ret_x = x And Form1.w_rook(i).ret_y = y Then
show_possible_move(Form1.w_rook(i).poss_mov())
End If
Next
Return "w_rook"
End If
Case 6
If player = 1 Then
For i As Integer = 0 To 7
If Form1.w_pawn(i).ret_x = x And Form1.w_pawn(i).ret_y = y Then
show_possible_move(Form1.w_pawn(i).poss_mov())
End If
Next
Return "w_pawn"
End If
Case -1
If player = 2 Then
show_possible_move(Form1.b_king.poss_mov())
Return "b_king"
End If
Case -2
If player = 2 Then
show_possible_move(Form1.b_queen.poss_mov())
Return "b_queen"
End If
Case -3
If player = 2 Then
For i As Integer = 0 To 1
If Form1.b_bishop(i).ret_x = x And Form1.b_bishop(i).ret_y = y Then
show_possible_move(Form1.b_bishop(i).poss_mov())
End If
Next
Return "b_bishop"
End If
Case -4
If player = 2 Then
For i As Integer = 0 To 1
If Form1.b_knight(i).ret_x = x And Form1.b_knight(i).ret_y = y Then
show_possible_move(Form1.b_knight(i).poss_mov())
End If
Next
Return "b_knight"
End If
Case -5
If player = 2 Then
For i As Integer = 0 To 1
If Form1.b_rook(i).ret_x = x And Form1.b_rook(i).ret_y = y Then
show_possible_move(Form1.b_rook(i).poss_mov())
End If
Next
Return "b_rook"
End If
Case -6
If player = 2 Then
For i As Integer = 0 To 7
If Form1.b_pawn(i).ret_x = x And Form1.b_pawn(i).ret_y = y Then
show_possible_move(Form1.b_pawn(i).poss_mov())
End If
Next
Return "b_pawn"
End If
Case Else
Return Nothing
End Select
End If
#Disable Warning BC42105 ' Function doesn't return a value on all code paths
End Function
#Enable Warning BC42105 ' Function doesn't return a value on all code paths

Public Sub re_back()


For i As Integer = 0 To 7
For j As Integer = 0 To 7
Form1.pb(i, j).BackgroundImage = Nothing
Next
Next
End Sub

Public Sub re_can_move()


For i As Integer = 0 To 7
For j As Integer = 0 To 7
can_move(i, j) = False
Next
Next
End Sub

Public Sub re_chk_white()


For i As Integer = 0 To 7
For j As Integer = 0 To 7
check_for_white(i, j) = False
Next
Next
End Sub

Public Sub re_chk_black()


For i As Integer = 0 To 7
For j As Integer = 0 To 7
check_for_black(i, j) = False
Next
Next
End Sub
Public Sub fill_chk_for_black()
re_chk_black()
For i As Integer = 0 To 7
Form1.w_pawn(i).fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.w_pawn(i).check_the_king(j, k) = True Then
check_for_black(j, k) = True
End If
Next
Next
Next

For i As Integer = 0 To 1
Form1.w_rook(i).fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.w_rook(i).check_the_king(j, k) = True Then
check_for_black(j, k) = True
End If
Next
Next
Next
For i As Integer = 0 To 1
Form1.w_bishop(i).fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.w_bishop(i).check_the_king(j, k) = True Then
check_for_black(j, k) = True
End If
Next
Next
Next

For i As Integer = 0 To 1
Form1.w_knight(i).fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.w_knight(i).check_the_king(j, k) = True Then
check_for_black(j, k) = True
End If
Next
Next
Next

Form1.w_queen.fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.w_queen.check_the_king(j, k) = True Then
check_for_black(j, k) = True
End If
Next
Next

End Sub

Public Sub fill_chk_for_white()


re_chk_white()
For i As Integer = 0 To 7
Form1.b_pawn(i).fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.b_pawn(i).check_the_king(j, k) = True Then
check_for_white(j, k) = True
End If
Next
Next
Next

For i As Integer = 0 To 1
Form1.b_rook(i).fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.b_rook(i).check_the_king(j, k) = True Then
check_for_white(j, k) = True
End If
Next
Next
Next
For i As Integer = 0 To 1
Form1.b_bishop(i).fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.b_bishop(i).check_the_king(j, k) = True Then
check_for_white(j, k) = True
End If
Next
Next
Next

For i As Integer = 0 To 1
Form1.b_knight(i).fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.b_knight(i).check_the_king(j, k) = True Then
check_for_white(j, k) = True
End If
Next
Next
Next

Form1.b_queen.fill_chk_king()
For j As Integer = 0 To 7
For k As Integer = 0 To 7
If Form1.b_queen.check_the_king(j, k) = True Then
check_for_white(j, k) = True
End If
Next
Next

End Sub

Public Sub show_chk()


w_in_danger = False
b_in_danger = False

For i As Integer = 0 To 7
For j As Integer = 0 To 7
If check_for_black(i, j) = True And Form1.b_king.x_pos = i And
Form1.b_king.y_pos = j Then
Form1.pb(i, j).BackgroundImage = My.Resources.check
b_in_danger = True
End If
Next
Next

For i As Integer = 0 To 7
For j As Integer = 0 To 7
If check_for_white(i, j) = True And Form1.w_king.x_pos = i And
Form1.w_king.y_pos = j Then
Form1.pb(i, j).BackgroundImage = My.Resources.check
w_in_danger = True
End If
Next
Next
End Sub

Public Sub show_possible_move(ByVal b As Boolean(,))


For i As Integer = 0 To 7
For j As Integer = 0 To 7
If b(i, j) = True Then
Form1.pb(i, j).BackgroundImage = My.Resources.V_Move
can_move(i, j) = True
End If
Next
Next
End Sub

Public Sub mov(ByVal selected, ByVal x, ByVal y, ByVal pre_x, ByVal pre_y)
Select Case selected
Case "w_king"
Form1.w_king.change_pos(x, y, pre_x, pre_y)
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 2
chk_winner(selected, x, y)
Case "w_queen"
Form1.w_queen.change_pos(x, y, pre_x, pre_y)
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 2
chk_winner(selected, x, y)
Case "w_bishop"
For i As Integer = 0 To 1
If Form1.w_bishop(i).ret_x = pre_x And Form1.w_bishop(i).ret_y = pre_y
Then
Form1.w_bishop(i).change_pos(x, y, pre_x, pre_y)
End If
Next
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 2
chk_winner(selected, x, y)
Case "w_knight"
For i As Integer = 0 To 1
If Form1.w_knight(i).ret_x = pre_x And Form1.w_knight(i).ret_y = pre_y
Then
Form1.w_knight(i).change_pos(x, y, pre_x, pre_y)
End If
Next
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 2
chk_winner(selected, x, y)
Case "w_rook"
For i As Integer = 0 To 1
If Form1.w_rook(i).ret_x = pre_x And Form1.w_rook(i).ret_y = pre_y Then
Form1.w_rook(i).change_pos(x, y, pre_x, pre_y)
End If
Next
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 2
chk_winner(selected, x, y)
Case "w_pawn"
For i As Integer = 0 To 7
If Form1.w_pawn(i).ret_x = pre_x And Form1.w_pawn(i).ret_y = pre_y
And board(x, y) <= 0 Then
Form1.w_pawn(i).change_pos(x, y, pre_x, pre_y)
End If
Next
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 2
chk_winner(selected, x, y)

Case "b_king"
Form1.b_king.change_pos(x, y, pre_x, pre_y)
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 1
chk_winner(selected, x, y)
Case "b_queen"
Form1.b_queen.change_pos(x, y, pre_x, pre_y)
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 1
chk_winner(selected, x, y)
Case "b_bishop"
For i As Integer = 0 To 1
If Form1.b_bishop(i).ret_x = pre_x And Form1.b_bishop(i).ret_y = pre_y
Then
Form1.b_bishop(i).change_pos(x, y, pre_x, pre_y)
End If
Next
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 1
chk_winner(selected, x, y)
Case "b_knight"
For i As Integer = 0 To 1
If Form1.b_knight(i).ret_x = pre_x And Form1.b_knight(i).ret_y = pre_y
Then
Form1.b_knight(i).change_pos(x, y, pre_x, pre_y)
End If
Next
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 1
chk_winner(selected, x, y)
Case "b_rook"
For i As Integer = 0 To 1
If Form1.b_rook(i).ret_x = pre_x And Form1.b_rook(i).ret_y = pre_y Then
Form1.b_rook(i).change_pos(x, y, pre_x, pre_y)
End If
Next
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 1
chk_winner(selected, x, y)
Case "b_pawn"
For i As Integer = 0 To 7
If Form1.b_pawn(i).ret_x = pre_x And Form1.b_pawn(i).ret_y = pre_y And
board(x, y) >= 0 Then
Form1.b_pawn(i).change_pos(x, y, pre_x, pre_y)
End If
Next
re_chk_white()
re_chk_black()
fill_chk_for_white()
fill_chk_for_black()
show_chk()
player = 1
chk_winner(selected, x, y)
Case Else

End Select

End Sub
End Class

PAWN.VB
Public Class pawn
Public x_pos, y_pos As Integer
Public piece_val As Integer
Private flags(7, 7) As Boolean
Public check_the_king(7, 7) As Boolean
Private pin As Boolean = False

Public Sub New(ByVal x, ByVal y, ByVal p_val)


x_pos = x
y_pos = y
piece_val = p_val
re_flags()
re_chk_king()

End Sub

Public Function ret_x() As Integer


Return x_pos
End Function
Public Function ret_y() As Integer
Return y_pos
End Function

Public Function ret_val() As Integer


Return piece_val
End Function

Public Function poss_mov() As Boolean(,)


re_flags()
If piece_val > 0 Then
white_mov()
End If
If piece_val < 0 Then
black_mov()
End If
Return flags
End Function

Public Sub white_mov()


If x_pos = 1 Then
If Chess.Form1.ga.board(x_pos + 1, y_pos) = 0 And x_pos
< 7 And pin = False Then
flags(x_pos + 1, y_pos) = True
End If
If Chess.Form1.ga.board(x_pos + 2, y_pos) = 0 And
Chess.Form1.ga.board(x_pos + 1, y_pos) = 0 And pin = False Then
flags(x_pos + 2, y_pos) = True
End If
If y_pos + 1 <= 7 And x_pos + 1 <= 7 Then
If Chess.Form1.ga.board(x_pos + 1, y_pos + 1) < 0
Then
flags(x_pos + 1, y_pos + 1) = True
End If
End If
If y_pos - 1 >= 0 And x_pos + 1 <= 7 Then
If Chess.Form1.ga.board(x_pos + 1, y_pos - 1) < 0
Then
flags(x_pos + 1, y_pos - 1) = True
End If
End If
Else
If x_pos + 1 <= 7 Then
If Chess.Form1.ga.board(x_pos + 1, y_pos) = 0 And
pin = False Then
flags(x_pos + 1, y_pos) = True
End If
End If
If y_pos + 1 <= 7 And x_pos + 1 <= 7 Then
If Chess.Form1.ga.board(x_pos + 1, y_pos + 1) < 0
Then
flags(x_pos + 1, y_pos + 1) = True
End If
End If

If y_pos - 1 >= 0 And x_pos + 1 <= 7 Then


If Chess.Form1.ga.board(x_pos + 1, y_pos - 1) < 0
Then
flags(x_pos + 1, y_pos - 1) = True
End If
End If
End If
pin = False

End Sub

Public Sub black_mov()


If x_pos = 6 Then
If Chess.Form1.ga.board(x_pos - 1, y_pos) = 0 And x_pos
> 0 And pin = False Then
flags(x_pos - 1, y_pos) = True
End If
If Chess.Form1.ga.board(x_pos - 2, y_pos) = 0 And
Chess.Form1.ga.board(x_pos - 1, y_pos) = 0 And pin = False Then
flags(x_pos - 2, y_pos) = True
End If
If y_pos + 1 <= 7 And x_pos - 1 >= 0 Then
If Chess.Form1.ga.board(x_pos - 1, y_pos + 1) > 0
Then
flags(x_pos - 1, y_pos + 1) = True
End If
End If
If y_pos - 1 >= 0 And x_pos - 1 >= 0 Then
If Chess.Form1.ga.board(x_pos - 1, y_pos - 1) > 0
Then
flags(x_pos - 1, y_pos - 1) = True
End If
End If
Else
If x_pos - 1 >= 0 Then
If Chess.Form1.ga.board(x_pos - 1, y_pos) = 0 And
pin = False Then
flags(x_pos - 1, y_pos) = True
End If
End If
If y_pos + 1 <= 7 And x_pos - 1 >= 0 Then
If Chess.Form1.ga.board(x_pos - 1, y_pos + 1) > 0
Then
flags(x_pos - 1, y_pos + 1) = True
End If
End If
If y_pos - 1 >= 0 And x_pos - 1 >= 0 Then
If Chess.Form1.ga.board(x_pos - 1, y_pos - 1) > 0
Then
flags(x_pos - 1, y_pos - 1) = True
End If
End If
End If
pin = False
End Sub

Public Sub re_flags()


For i As Integer = 0 To 7
For j As Integer = 0 To 7
flags(i, j) = False
Next
Next
End Sub

Public Sub re_chk_king()


For i As Integer = 0 To 7
For j As Integer = 0 To 7
check_the_king(i, j) = False
Next
Next
End Sub

Public Sub fill_chk_king()


pin = True
poss_mov()
For i As Integer = 0 To 7
For j As Integer = 0 To 7
If flags(i, j) = True Then
check_the_king(i, j) = True
Else
check_the_king(i, j) = False
End If
Next
Next
End Sub

Public Sub change_pos(ByVal x, ByVal y, ByVal pre_x, ByVal


pre_y)
Form1.ga.board(x, y) = Form1.ga.board(pre_x, pre_y)
Form1.ga.board(pre_x, pre_y) = 0
x_pos = x
y_pos = y
fill_chk_king()
End Sub
End Class

QUEEN.VB
Public Class queen
Public x_pos, y_pos As Integer
Public piece_val As Integer
Private flags(7, 7) As Boolean
Public check_the_king(7, 7) As Boolean

Public Sub New(ByVal x, ByVal y, ByVal p_val) 'color=+ve val


if white color=-ve if black
x_pos = x
y_pos = y
piece_val = p_val
re_flags()

End Sub

Public Function ret_x() As Integer


Return x_pos
End Function

Public Function ret_y() As Integer


Return y_pos
End Function

Public Function ret_val() As Integer


Return piece_val
End Function

Public Function poss_mov() As Boolean(,) ''to show possible


moves
re_flags()
If piece_val > 0 Then
white_mov()
End If
If piece_val < 0 Then
black_mov()
End If
Return flags
End Function

Public Sub white_mov()


Dim x As Integer = x_pos
Dim y As Integer = y_pos

While (x < 7 And y > 0)


x = x + 1
y = y - 1
If Form1.ga.board(x, y) <= 0 Then
flags(x, y) = True
If Form1.ga.board(x, y) < 0 Then
Exit While
End If
Else
Exit While
End If
End While

x = x_pos
y = y_pos
While (x > 0 And y < 7)
x = x - 1
y = y + 1
If Form1.ga.board(x, y) <= 0 Then
flags(x, y) = True
If Form1.ga.board(x, y) < 0 Then
Exit While
End If
Else
Exit While
End If
End While

x = x_pos
y = y_pos
While (x < 7 And y < 7)
x = x + 1
y = y + 1
If Form1.ga.board(x, y) <= 0 Then
flags(x, y) = True
If Form1.ga.board(x, y) < 0 Then
Exit While
End If
Else
Exit While
End If
End While

x = x_pos
y = y_pos
While (x > 0 And y > 0)
x = x - 1
y = y - 1
If Form1.ga.board(x, y) <= 0 Then
flags(x, y) = True
If Form1.ga.board(x, y) < 0 Then
Exit While
End If
Else
Exit While
End If
End While

If x_pos > 0 Then


For i As Integer = x_pos - 1 To 0 Step -1
If Form1.ga.board(i, y_pos) <= 0 Then
flags(i, y_pos) = True
If Form1.ga.board(i, y_pos) < 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
If x_pos <= 7 Then
For i As Integer = x_pos + 1 To 7
If Form1.ga.board(i, y_pos) <= 0 Then
flags(i, y_pos) = True
If Form1.ga.board(i, y_pos) < 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If

If y_pos > 0 Then


For i As Integer = y_pos - 1 To 0 Step -1
If Form1.ga.board(x_pos, i) <= 0 Then
flags(x_pos, i) = True
If Form1.ga.board(x_pos, i) < 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
If y_pos <= 7 Then
For i As Integer = y_pos + 1 To 7
If Form1.ga.board(x_pos, i) <= 0 Then
flags(x_pos, i) = True
If Form1.ga.board(x_pos, i) < 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If

End Sub

Public Sub black_mov()


Dim x As Integer = x_pos
Dim y As Integer = y_pos

While (x < 7 And y > 0)


x = x + 1
y = y - 1
If Form1.ga.board(x, y) >= 0 Then
flags(x, y) = True
If Form1.ga.board(x, y) > 0 Then
Exit While
End If
Else
Exit While
End If
End While

x = x_pos
y = y_pos
While (x > 0 And y < 7)
x = x - 1
y = y + 1
If Form1.ga.board(x, y) >= 0 Then
flags(x, y) = True
If Form1.ga.board(x, y) > 0 Then
Exit While
End If
Else
Exit While
End If
End While

x = x_pos
y = y_pos
While (x < 7 And y < 7)
x = x + 1
y = y + 1
If Form1.ga.board(x, y) >= 0 Then
flags(x, y) = True
If Form1.ga.board(x, y) > 0 Then
Exit While
End If
Else
Exit While
End If
End While

x = x_pos
y = y_pos
While (x > 0 And y > 0)
x = x - 1
y = y - 1
If Form1.ga.board(x, y) >= 0 Then
flags(x, y) = True
If Form1.ga.board(x, y) > 0 Then
Exit While
End If
Else
Exit While
End If
End While

If x_pos > 0 Then


For i As Integer = x_pos - 1 To 0 Step -1
If Form1.ga.board(i, y_pos) >= 0 Then
flags(i, y_pos) = True
If Form1.ga.board(i, y_pos) > 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
If x_pos <= 7 Then
For i As Integer = x_pos + 1 To 7
If Form1.ga.board(i, y_pos) >= 0 Then
flags(i, y_pos) = True
If Form1.ga.board(i, y_pos) > 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If

If y_pos > 0 Then


For i As Integer = y_pos - 1 To 0 Step -1
If Form1.ga.board(x_pos, i) >= 0 Then
flags(x_pos, i) = True
If Form1.ga.board(x_pos, i) > 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
If y_pos <= 7 Then
For i As Integer = y_pos + 1 To 7
If Form1.ga.board(x_pos, i) >= 0 Then
flags(x_pos, i) = True
If Form1.ga.board(x_pos, i) > 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
End Sub

Public Sub re_flags()


For i As Integer = 0 To 7
For j As Integer = 0 To 7
flags(i, j) = False
Next
Next
End Sub

Public Sub fill_chk_king()


poss_mov()
For i As Integer = 0 To 7
For j As Integer = 0 To 7
If flags(i, j) = True Then
check_the_king(i, j) = True
Else
check_the_king(i, j) = False
End If
Next
Next
End Sub

Public Sub change_pos(ByVal x, ByVal y, ByVal pre_x, ByVal


pre_y)
Form1.ga.board(x, y) = Form1.ga.board(pre_x, pre_y)
Form1.ga.board(pre_x, pre_y) = 0
x_pos = x
y_pos = y
End Sub
End Class

ROOK.VB
Public Class rook
Public x_pos, y_pos As Integer
Public piece_val As Integer
Private flags(7, 7) As Boolean
Public check_the_king(7, 7) As Boolean

Public Sub New(ByVal x, ByVal y, ByVal p_val)


x_pos = x
y_pos = y
piece_val = p_val
re_flags()

End Sub

Public Function ret_x() As Integer


Return x_pos
End Function

Public Function ret_y() As Integer


Return y_pos
End Function

Public Function ret_val() As Integer


Return piece_val
End Function

Public Function poss_mov() As Boolean(,)


re_flags()
If piece_val > 0 Then
white_mov()
End If
If piece_val < 0 Then
black_mov()
End If
Return flags
End Function

Public Sub white_mov()


If x_pos > 0 Then
For i As Integer = x_pos - 1 To 0 Step -1
If Form1.ga.board(i, y_pos) <= 0 Then
flags(i, y_pos) = True
If Form1.ga.board(i, y_pos) < 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
If x_pos <= 7 Then
For i As Integer = x_pos + 1 To 7
If Form1.ga.board(i, y_pos) <= 0 Then
flags(i, y_pos) = True
If Form1.ga.board(i, y_pos) < 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If

If y_pos > 0 Then


For i As Integer = y_pos - 1 To 0 Step -1
If Form1.ga.board(x_pos, i) <= 0 Then
flags(x_pos, i) = True
If Form1.ga.board(x_pos, i) < 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
If y_pos <= 7 Then
For i As Integer = y_pos + 1 To 7
If Form1.ga.board(x_pos, i) <= 0 Then
flags(x_pos, i) = True
If Form1.ga.board(x_pos, i) < 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
End Sub

Public Sub black_mov()


If x_pos > 0 Then
For i As Integer = x_pos - 1 To 0 Step -1
If Form1.ga.board(i, y_pos) >= 0 Then
flags(i, y_pos) = True
If Form1.ga.board(i, y_pos) > 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
If x_pos <= 7 Then
For i As Integer = x_pos + 1 To 7
If Form1.ga.board(i, y_pos) >= 0 Then
flags(i, y_pos) = True
If Form1.ga.board(i, y_pos) > 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If

If y_pos > 0 Then


For i As Integer = y_pos - 1 To 0 Step -1
If Form1.ga.board(x_pos, i) >= 0 Then
flags(x_pos, i) = True
If Form1.ga.board(x_pos, i) > 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
If y_pos <= 7 Then
For i As Integer = y_pos + 1 To 7
If Form1.ga.board(x_pos, i) >= 0 Then
flags(x_pos, i) = True
If Form1.ga.board(x_pos, i) > 0 Then
Exit For
End If
Else
Exit For
End If
Next
End If
End Sub

Public Sub re_flags()


For i As Integer = 0 To 7
For j As Integer = 0 To 7
flags(i, j) = False
Next
Next
End Sub

Public Sub fill_chk_king()


poss_mov()
For i As Integer = 0 To 7
For j As Integer = 0 To 7
If flags(i, j) = True Then
check_the_king(i, j) = True
Else
check_the_king(i, j) = False
End If
Next
Next
End Sub

Public Sub change_pos(ByVal x, ByVal y, ByVal pre_x, ByVal


pre_y)
Form1.ga.board(x, y) = Form1.ga.board(pre_x, pre_y)
Form1.ga.board(pre_x, pre_y) = 0
x_pos = x
y_pos = y
End Sub
End Class

You might also like