Professional Documents
Culture Documents
1931018-Krshnapriya-Vb Cat 2 Record
1931018-Krshnapriya-Vb Cat 2 Record
LABORATORY
CAT 2
SUBMITTED BY:
KRSHNA PRIYA .R
19 31 018
2nd YEAR MSC SS
INDEX
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:
Inputs
Test Case : 1234 1223 1233 2344
Krshna priya .R
899
12/10/2025
Oviya
1233 1223 1222 1233
23400
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:
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.
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
caranimation.Image = bmp
currDirection = "Up"
moveup.Start()
End Sub
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.
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
Input:
Test Case : Krshna priya
12345332345432
Commercial
Monthly
1200
2200
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
Else
bill = (100 * 0) + (100 * 3.5) + (300 * 4.6) + (uc - 500) * 6.6 +
50
End If
billlbl.Text = CStr(bill)
End Sub
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
pu = putxt.Text
cu = cutxt.Text
uc = cu - pu
uclbl.Text = uc
bill = uc * 6.35
billlbl.Text = CStr(bill)
End Sub
End Sub
End Class
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
TOKEN GENERATION:
Imports System.Data.SqlClient
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
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.
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 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
all_objects()
ga.re_can_move()
ga.show()
ga.re_back()
ga.fill_chk_for_black()
ga.fill_chk_for_white()
End Sub
ga = New game()
End Sub
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
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
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
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
End Sub
Private Sub MaskedTextBox1_MaskInputRejected(sender As Object, e As
MaskInputRejectedEventArgs) Handles MaskedTextBox1.MaskInputRejected
End Sub
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()
re_chk_black()
re_chk_white()
End Sub
Public Sub chk_winner(ByVal selected, ByVal x, ByVal y)
show()
For i As Integer = 0 To 7
For j As Integer = 0 To 7
Case Else
Form1.pb(i, j).Image = Nothing
End Select
show_chk()
Next
Next
End Sub
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
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
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 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
End Sub
End Sub
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
End Sub
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
End Sub
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
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
End Sub