[pick the date] - jay's programsjaysprograms.com/downloads/documentation.pdf · [pick the...

45
Authored By Jason Bilik Version 1.3

Upload: lamhuong

Post on 05-Aug-2019

212 views

Category:

Documents


0 download

TRANSCRIPT

Au

th

ore

d B

y J

aso

n B

ilik

Ve

rs

ion

1.3

[Pick the date]

2

CONTENTS

Introduction............................................................................................................................................................. 4

This Product was made as a Colaboration between Class and a part time Job. .......................................... 4

Login Form .............................................................................................................................................................. 5

Main Graphical Interface ....................................................................................................................................... 6

Main Graphical Interface ....................................................................................................................................... 7

About Box ................................................................................................................................................................ 8

Database .................................................................................................................................................................. 9

WebBrowser .......................................................................................................................................................... 10

The WebBrowser is located in the Third Tab ............................................................................................... 10

Calculator .............................................................................................................................................................. 11

Loan Calculator ..................................................................................................................................................... 12

Word Processor...................................................................................................................................................... 13

Our engineers are working on getting you the ultimate experience in Version 1.4 ................................... 13

Word Processor Menu ........................................................................................................................................... 14

Word Document Menu .......................................................................................................................................... 15

Hidden Content ..................................................................................................................................................... 16

Errors & Help ........................................................................................................................................................ 17

Module Code .......................................................................................................................................................... 19

Module Code .......................................................................................................................................................... 20

Main Graphical Interface Code ............................................................................................................................ 21

Main Graphical Interface Code ............................................................................................................................ 22

Main Graphical Interface Code ............................................................................................................................ 23

Main Graphical Interface Code ............................................................................................................................ 24

Main Graphical Interface Code ............................................................................................................................ 25

Calculator Code ..................................................................................................................................................... 26

Calculator Code ..................................................................................................................................................... 27

Loan calculator Code ............................................................................................................................................ 28

Word Processor Code ............................................................................................................................................ 29

Word Processor Code ............................................................................................................................................ 30

Word Processor Code ............................................................................................................................................ 31

Word Processor Code ............................................................................................................................................ 32

Word Processor Code ............................................................................................................................................ 33

[Pick the date]

3

CONTENTS

Word Processor Code ............................................................................................................................................ 34

Login Form Code ................................................................................................................................................... 35

Tic Tac Toe Code ................................................................................................................................................... 36

Tic Tac Toe Code ................................................................................................................................................... 37

Tic Tac Toe Code ................................................................................................................................................... 38

Tic Tac Toe Code ................................................................................................................................................... 39

Tic Tac Toe Code ................................................................................................................................................... 40

Tic Tac Toe Code ................................................................................................................................................... 41

Tic Tac Toe Code ................................................................................................................................................... 42

Tic Tac Toe Code ................................................................................................................................................... 43

Tic Tac Toe Code ................................................................................................................................................... 44

Tic Tac Toe Code ................................................................................................................................................... 45

CONTENTS

[Pick the date]

4

INTRODUCTION

THIS PRODUCT WAS MADE AS A COLABORATION BETWEEN CLASS AND A PART TIME

JOB.

As a Framer that builds Houses I’ve noticed my Employers having a tough time calculating the

amount of money the spent on all facets of their company. They are not very Proficient with computers so I

thought I would help them as well as maximize knowledge within this domain of programing.

THE LOGO:

This logo reminds me of the stacks of wood we uncover at ever new House that we work on. I wanted

this same feeling to resonate with the individual handling the experience.

I even went so far as to Make the outer edges circular for a Neater design that is Similar to the

Professional Microsoft icons. Needless to say a fresh design is More appealing than one lacking.

Currently Running:

VERSION 1.3

Has its Own Database Implemented within the Program with Adding, Changing and Removing

Properties. A Word Processor that Writes and saves Rich Text Documents, a Web Browser, a Loan

Calculator, and a regular Equational Calculator. Also a Hidden Game is somewhere within confines of this

Program.

“Software engineers’ are currently working on Version 1.4 to include More Functionality. A

Wage Calculator, New Game, and Upgraded Word Processor with capabilities of Microsoft

Word.”

Head Software Engineer: Jason Bilik

[Pick the date]

5

LOGIN FORM

Our Login Form is Focused on Simplicity in Version 1.3 as you can see the User Name is Present.

The User Name appears on Form Load. Only One user is set Open the Database Currently, Version 1.4 is

currently being Worked on to fix this issue and allow Multiple Users to Enter, With Privileges for “Admin” of

course. The Program allows you to enter without a password the before the password is set.

THE PASSWORD

The Password is Set in the form in the Initial Form Window. It is recommended that the new

password is set when first accessing Framing Inventory.

In the options menu you can find the option to do so:

Entering the Password into this Box Sets the Password access.

[Pick the date]

6

MAIN GRAPHICAL INTERFACE

Upon Login in you the User will Stumble Upon the Input Tab (Aka the Initial Greeting)

The End Button Terminates the Program and the Blue HyperLink with the text ”Order Materials?”

opens a HomeDepot Webpage. The textbox directly across from material makes all text capitalized for inputs

such as “2 X 4 FT”, instead of “2 x 4 ft”.

Data Input

This collumn was made to allow data input

in a more Visually appealing Graphical

Interface.

There is a built in calculation function that

is called upon when the user leaves the

textboxes and checks the Check box to keep

the data Updated at all times.

Data Is formatted upon calculation as well.

The Grayed text boxes are readonly.

Save & Clear

The save button saves the Data to the

database it is the acessed when tabbing

(using Tab key) throught the texboxes

after calculations are complete.

When save is clicked the focus is set to the

Material type combo box.

Clear is used to clear the data from text

boxes.

[Pick the date]

7

MAIN GRAPHICAL INTERFACE

THE FILE DROP DOWN MENU IS USED TO OPEN NEW WINDOWS IN THIS PROGRAM AS

WELL AS TERMINATE IT.

Word Processor: Opens the Word Processor Window

Calculator: Opens the Calculator Window

Loan Calculator: Opens the Loan Calculator Window

THE HELP DROP DOWN MENU OPTION

Contains the Help and About Menu Options.

Help opens a Help Txt File with a link to this User’s Manual. As well as other interesting Tidbits.

[Pick the date]

8

ABOUT BOX

THE ABOUT MENU OPTION OPENS THE ABOUT BOX

THIS BOX IS UPDATED WITH EACH NEW VERSION UPDATE.

This area will contain Information on the Current Version Running and Additions in Newer

Versions. Updates can be set up on this Program without Damaging the Integrity of the Data.

[Pick the date]

9

DATABASE

Function of Inputs

The textboxes here reciprocate data

from the table. this is an interactive

database clicking on a Row will

allow you to call the data to the text

boxes for manipulation.

Remove: removes the selected data

row from the table.

Save: saves the Manipulated data to

the database

the directional Buttons help

navigate throght the records.

Data that is considered as currency

is programed to format as such.

Dates

Dates save in blocks, items

are tied to a specific date and

will save under objects with

the same date.

The dates are not shown in

the grid but are shown in the

Function of Inputs collumn.

[Pick the date]

10

WEBBROWSER

THE WEBBROWSER IS LOCATED IN THE THIRD TAB

The textbox on top is used to Navigate websites. Either Press enter or Click the Go button to

Navigate. Directly next to go is a Refresh, Back Navigate, Forward Navigate and HomePage Button.

HomePage is Hard Coded to Return to Google.

VERSION 1.4 WILL FEATURE A SETABLE HOMEPAGE

[Pick the date]

11

CALCULATOR

The below Label is where the Equation is Stored

Functions

Arthmethatic Functions all have

a Tool tip when hovered over.

Order of Operations applies to the

equation written.

When an error occurs there will

be no return data in the label box

above.

When multiplying always pu an

multiplication sign in front of the

parantheses. an equation such as

“2(3+4)” Returns an Error.

The data can only be clicked in

throught the buttons.

Enter is Clicked at the end of an

finished equation to push data.

Behind the scenes a Visual Basic

Comipler takes this Data in the Label

and Works throught it.

….Be Patient data it may take

a moment to Calculate.

[Pick the date]

12

LOAN CALCULATOR

The loan calculator calculates Interest and principal payments

every month to pay off a loan scheduled to a specific percentage.

This calculator can be used for loans for a house, or a business

opportunity.

Input

The Periodic Payment must be

calculated first .

Then a table can be created

with “Create Table” button.

Clear is used to clear both the

list box and the textboxes.

[Pick the date]

13

WORD PROCESSOR

THE WORD PROCESSOR THAT COMES WITH THE PROGRAM CAN BE USED AS A

STANDALONE APPLICATION.

The Word Processor has a tool strip that can manipulate the text. Align features, Copy, Cut and

Paste. Insert Pictures and Text along with Print Preview and Print.

This Word Processor can be used to record comments and Form reports.

OUR ENGINEERS ARE WORKING ON GETTING YOU THE ULTIMATE EXPERIENCE IN

VERSION 1.4

[Pick the date]

14

WORD PROCESSOR MENU

FILE DROP DOWN MENU

In this menu the user can open a new file or existing one. Save and Save as are only available in this menu.

The Hot keys are listed parallel to the Names of the Drop Down options.

EDIT DROP DOWN MENU

The Hot keys for this menu are also listed parallel to the Names of the option. The options are an extension

of the Context menu. Select all, selects all the text and Upper sends all the highlighted data to upper case

asci.

The context menu on the right Presents its self When Right -clicking Inside the txt

Document. The context menu works more efficiently when highlighting text.

[Pick the date]

15

WORD DOCUMENT MENU

FORMAT DROP DOWN MENU

This Menu is also an extension of the Context menu. Allowing users to use multiple paths to the same

result. The Align text option extends out to Show options; Right, Left and Center.

HELP FILE DROP DOWN MENU

This Menu also contain the About Box Form page. The help text file is a file just attuned to this Word

Processor.

“For additional help content contact [email protected]

[Pick the date]

16

HIDDEN CONTENT

A Tic Tac Toe Game is Hidden within the Entry Form.

The Pc Start button Prompts the computer to start the game.

Restart is used to restart game and allow a restart after the game comes to a tie.

Here’s the Clue:

[Pick the date]

17

ERRORS & HELP

MOST OF THE ERRORS HAVE BEEN PATCHED BY NOW WITH VERSION 1.3

But there is one significant error that Disturbs the Program.

Any Input for Materials in the Input and Database tab Must be only 10 Characters (Yes, that includes

Spaces). Otherwise, an error will occur.

Also, Pc Start on the Tic Tac Toe Window seems to give the Player an extra turn.

HELP IS FOUND IN THE DROP DOWN HELP MENU.

“For additional help content contact [email protected]

[Pick the date]

18

THE CODE

{Left Blank Intentionally}

[Pick the date]

19

MODULE CODE

Module VariablesandFuctions Public Num, n As Integer Public P, PVIFA, r, PI, PP, Year As Double Public I As Decimal Public a As Double Public f As Double Public b As Double Public House As String Public taxRate As Decimal = 0.07D Public Subtotal As Decimal Public Total As Decimal Public PPU As Decimal Public Quan As Integer Public Tax As Decimal Public saved As Integer Public Grandtotal As Decimal Public Material As String Public Sub calcs() Try If frmInvpro.txtPPU.Text = "" Or frmInvpro.txtQuan.Text = "" Then Exit Sub PPU = CDec(frmInvpro.txtPPU.Text) Quan = CInt(frmInvpro.txtQuan.Text) Subtotal = Quan * PPU Tax = Subtotal * taxRate Total = Tax + Subtotal frmInvpro.lblsubtxt.Text = Subtotal frmInvpro.lblcalc.Text = Total frmInvpro.lbltax.Text = Tax frmInvpro.lblcalc.Text = FormatCurrency(Total, 2) frmInvpro.lblsubtxt.Text = FormatCurrency(Subtotal, 2) frmInvpro.lbltax.Text = FormatCurrency(Tax, 2) frmInvpro.txtPPU.Text = FormatCurrency(PPU, 2) Catch Beep() MessageBox.Show("Something is Wrong Recheck Your Data") End Try End Sub Public Function Eval(ByVal command As String) As Object Dim MyProvider As New VBCodeProvider 'Create a new VB Code Compiler Dim cp As New CodeDom.Compiler.CompilerParameters 'Create a new Compiler parameter object. cp.GenerateExecutable = False 'Don't create an object on disk cp.GenerateInMemory = True 'But do create one in memory. 'If cp.OutputAssembly is used with a VBCodeProvider, it seems to want to read before it is executed. 'See C# CodeBank example for explanation of why it was used. 'the below is an empty VB.NET Project with a function that simply returns the value of our command parameter. Dim ClassName As String = "class" & Now.Ticks Dim TempModuleSource As String = "Imports System" & Environment.NewLine & "Namespace ns " & Environment.NewLine & " Public Class " & ClassName & Environment.NewLine &

[Pick the date]

20

MODULE CODE

" Public Shared Function Evaluate()" & Environment.NewLine & " Return (" & command & ")" & Environment.NewLine & " End Function" & Environment.NewLine & " End Class" & Environment.NewLine & "End Namespace" 'Create a compiler output results object and compile the source code. Dim cr As CodeDom.Compiler.CompilerResults = MyProvider.CompileAssemblyFromSource(cp, TempModuleSource) If cr.Errors.Count > 0 Then 'If the expression passed is invalid or "", the compiler will generate errors. 'Throw New ArgumentOutOfRangeException("Invalid Expression - please use something VB could evaluate") Return Nothing Else 'Find our Evaluate method. Dim methInfo As Reflection.MethodInfo = cr.CompiledAssembly.GetType("ns." & ClassName).GetMethod("Evaluate") 'Invoke it on nothing, so that we can get the return value Return methInfo.Invoke(methInfo, New Object() {}) End If End Function

End Module

[Pick the date]

21

MAIN GRAPHICAL INTERFACE CODE

Option Strict On Imports System.IO Imports System.Security.Cryptography Public Class frmInvpro Private Sub frmInvpro_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.TableTableAdapter.Fill(Me.FrmInvDataBaseDataSet.Table) Dim DtmSystemdate As Date DtmSystemdate = Today txtWeb.Text = ("www.Google.com") WebBrowser.Navigate(txtWeb.Text) StatusStrip1.Hide() colFormItems.Add(Lblsub) colFormItems.Add(lblQuan) colFormItems.Add(lblPpu) colFormItems.Add(lblMat) colFormItems.Add(lbltotal) colFormItems.Add(lblTaxlabel) colFormItems.Add(lblMt) colFormItems.Add(lblDate) TimerMail.Start() Me.WindowState = FormWindowState.Maximized tbHoursIntake.Show() End Sub #Region "GobalDims" Dim colFormItems As New Collection() ' Key word New is very important Dim ctrlFormItems As Control ' Used to iterate the FormItems collection Dim count As Integer Dim LstBoxTotal As Decimal Dim countDb As Integer = 0 #End Region #Region "Buttons" Private Sub btnEnd_Click(sender As Object, e As EventArgs) Handles btnEnd.Click Dim Result = MsgBox("Have you Saved Your Data?", MsgBoxStyle.YesNo) If Result = MsgBoxResult.Yes Then End End Sub Private Sub btnsave_Click(sender As Object, e As EventArgs) Handles btnsave.Click TableBindingSource.AddNew() DateDateTimePicker.Text = DateTimePicker1.Text Material_typeTextBox.Text = ComBxMat.Text MaterialTextBox.Text = txtmat.Text QuatityTextBox.Text = txtQuan.Text Price_Per_UnitTextBox.Text = txtPPU.Text Sub_TotalTextBox.Text = lblsubtxt.Text TaxTextBox.Text = lbltax.Text TotalTextBox.Text = lblcalc.Text Try Me.Validate() Me.TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.FrmInvDataBaseDataSet) Catch ex As Exception MessageBox.Show(ex.Message) End Try ComBxMat.Focus() End Sub Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles pbxDI.Click

[Pick the date]

22

MAIN GRAPHICAL INTERFACE CODE

frmGame.ShowDialog() End Sub Private Sub BtnClear_Click(sender As Object, e As EventArgs) Handles BtnClear.Click txtmat.Text = String.Empty txtPPU.Text = String.Empty txtQuan.Text = String.Empty lblcalc.Text = String.Empty lblsubtxt.Text = String.Empty lbltax.Text = String.Empty End Sub Private Sub ChkTax_CheckedChanged(sender As Object, e As EventArgs) Handles ChkTax.CheckedChanged If ChkTax.Checked = True Then taxRate = CDec(0.00) Call calcs() If ChkTax.Checked = False Then taxRate = 0.07D Call calcs() End Sub #End Region #Region "Input" Private Sub txtQuan_LostFocus(sender As Object, e As EventArgs) Handles txtQuan.LostFocus StatusStrip1.Hide() If txtQuan.Text = "" Then Exit Sub If IsNumeric(txtQuan.Text) Then txtQuan.Text = FormatNumber(txtQuan.Text, 0) Else MessageBox.Show("Enter only numbers for Quantity") End If Call calcs() End Sub Private Sub txtPPU_LostFocus(sender As Object, e As EventArgs) Handles txtPPU.LostFocus StatusStrip1.Hide() If txtPPU.Text = "" Then Exit Sub If IsNumeric(txtPPU.Text) Then txtPPU.Text = FormatCurrency(txtPPU.Text, 2) Else MessageBox.Show("Enter only numbers for Price Per Unit") End If Call calcs() End Sub Private Sub txtQuan_GotFocus(sender As Object, e As EventArgs) Handles txtQuan.GotFocus StatusStrip1.Show() tsslInv.Text = "Enter only Numbers For Quantity" tsslInv.ForeColor = Color.Red End Sub Private Sub txtPPU_GotFocus(sender As Object, e As EventArgs) Handles txtPPU.GotFocus StatusStrip1.Show() tsslInv.Text = "Enter only Numbers For Price Per Unit" tsslInv.ForeColor = Color.Red End Sub Private Sub txtmat_LostFocus(sender As Object, e As EventArgs) Handles txtmat.LostFocus txtmat.Text = txtmat.Text.Trim.ToUpper End Sub Private Sub LLHomeDepot_MouseClick(sender As Object, e As MouseEventArgs) Handles LLHomeDepot.MouseClick Process.Start("Http://www.HomeDepot.com") End Sub #End Region

[Pick the date]

23

MAIN GRAPHICAL INTERFACE CODE

#Region "Menu" Private Sub mnuExit_Click(sender As Object, e As EventArgs) Handles mnuExit.Click Me.Close() End Sub Private Sub mnuhelp_Click(sender As Object, e As EventArgs) Handles mnuhelp.Click Process.Start("Notepad", "help") End Sub Private Sub mnuHelpAbout_Click(sender As Object, e As EventArgs) Handles mnuHelpAbout.Click frmAboutBx.ShowDialog() End Sub Private Sub LoanCalculatorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoanCalculatorToolStripMenuItem.Click frmLoanCalculator.ShowDialog() End Sub Private Sub CalculatorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CalculatorToolStripMenuItem.Click frmCalculator.ShowDialog() End Sub Private Sub ChangePasswordToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ChangePasswordToolStripMenuItem.Click Dim FileName As System.IO.StreamWriter Dim InputLine As String Try FileName = File.CreateText("NotPasword.txt") InputLine = InputBox("Enter new Password", "PassWord Manager") FileName.WriteLine(InputLine) FileName.Close() Catch MessageBox.Show("Sorry, the file cannot be created.") End Try End Sub Private Sub WordProcessorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles WordProcessorToolStripMenuItem.Click frmWordProcessor.Show() End Sub #End Region #Region "WebBrowser" Private Sub btnback_Click(sender As Object, e As EventArgs) Handles btnback.Click WebBrowser.GoBack() End Sub Private Sub btnforward_Click(sender As Object, e As EventArgs) Handles btnforward.Click WebBrowser.GoForward() End Sub Private Sub WebBrowser_progresschanged(sender As Object, e As WebBrowserProgressChangedEventArgs) Handles WebBrowser.ProgressChanged lbldocument.Text = WebBrowser.StatusText If lbldocument.Text = "Done" Then lbldocument.Visible = False End If End Sub Private Sub btnhome_Click(sender As Object, e As EventArgs) Handles btnhome.Click WebBrowser.Url = New Uri("https://www.google.com") End Sub Private Sub BtnGo_Click(sender As Object, e As EventArgs) Handles BtnGo.Click WebBrowser.Navigate(txtWeb.Text)

[Pick the date]

24

MAIN GRAPHICAL INTERFACE CODE

If txtWeb.Text.Contains(".com") Or txtWeb.Text.Contains(".org") Or txtWeb.Text.Contains(".net") Then Try WebBrowser.Url = New Uri(txtWeb.Text) Catch ex As UriFormatException WebBrowser.Url = New Uri("https://" + txtWeb.Text) txtWeb.Text = ("https://" + txtWeb.Text) End Try Else WebBrowser.Url = New Uri("https://www.google.com/#q=" & txtWeb.Text) End If End Sub Private Sub webBrowser_Navigated(ByVal sender As Object, ByVal e As WebBrowserNavigatedEventArgs) Handles WebBrowser.Navigated txtWeb.Text = WebBrowser.Url.ToString() End Sub Private Sub btnRefr_Click(sender As Object, e As EventArgs) Handles btnRefr.Click WebBrowser.Refresh() End Sub Private Sub txtWeb_KeyDown(sender As Object, e As KeyEventArgs) Handles txtWeb.KeyDown If e.KeyCode = Keys.Enter Then BtnGo.PerformClick() e.SuppressKeyPress = True End If End Sub #End Region #Region "Database" Private Sub btnPrevious_Click(sender As Object, e As EventArgs) Handles btnPrevious.Click TableBindingSource.MovePrevious() End Sub Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click Me.TableBindingSource.MoveNext() End Sub Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click Try Me.TableBindingSource.RemoveCurrent() Catch ex As Exception MessageBox.Show(ex.Message) End Try Try Me.Validate() Me.TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.FrmInvDataBaseDataSet) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub TimerMail_Tick(sender As Object, e As EventArgs) Handles TimerMail.Tick count = TableBindingSource.Count If CBool(CInt(count > 1) And 2) Then btnPrevious.Visible = True btnNext.Visible = True End If If CBool(CInt(count <= 1) And 2) Then btnPrevious.Visible = False btnNext.Visible = False

[Pick the date]

25

MAIN GRAPHICAL INTERFACE CODE

End If End Sub Private Sub TotalTextBox_TextChanged(sender As Object, e As EventArgs) Handles TotalTextBox.TextChanged TotalTextBox.Text = FormatCurrency(TotalTextBox.Text) Sub_TotalTextBox.Text = FormatCurrency(Sub_TotalTextBox.Text) TaxTextBox.Text = FormatCurrency(TaxTextBox.Text) Price_Per_UnitTextBox.Text = FormatCurrency(Price_Per_UnitTextBox.Text) End Sub #End Region

End Class

[Pick the date]

26

CALCULATOR CODE

Option Strict On Public Class frmCalculator Private Sub BtnClear2_Click(sender As Object, e As EventArgs) Handles BtnClear2.Click lblcalculator.Text = String.Empty End Sub Private Sub BtnEnter_Click(sender As Object, e As EventArgs) Handles BtnEnter.Click lbleq.Text = String.Empty lbleq.Text = lblcalculator.Text & "=" lblcalculator.Text = CType(Eval(lblcalculator.Text), String) End Sub Private Sub Btn1_Click(sender As Object, e As EventArgs) Handles Btn1.Click lblcalculator.Text = (lblcalculator.Text & 1) End Sub Private Sub Btn2_Click(sender As Object, e As EventArgs) Handles Btn2.Click lblcalculator.Text = (lblcalculator.Text & 2) End Sub Private Sub Btn3_Click(sender As Object, e As EventArgs) Handles Btn3.Click lblcalculator.Text = (lblcalculator.Text & 3) End Sub Private Sub Btn4_Click(sender As Object, e As EventArgs) Handles Btn4.Click lblcalculator.Text = (lblcalculator.Text & 4) End Sub Private Sub Btn5_Click(sender As Object, e As EventArgs) Handles Btn5.Click lblcalculator.Text = (lblcalculator.Text & 5) End Sub Private Sub Btn6_Click(sender As Object, e As EventArgs) Handles Btn6.Click lblcalculator.Text = (lblcalculator.Text & 6) End Sub Private Sub Btn7_Click(sender As Object, e As EventArgs) Handles Btn7.Click lblcalculator.Text = (lblcalculator.Text & 7) End Sub Private Sub Btn8_Click(sender As Object, e As EventArgs) Handles Btn8.Click lblcalculator.Text = (lblcalculator.Text & 8) End Sub Private Sub Btn9_Click(sender As Object, e As EventArgs) Handles Btn9.Click lblcalculator.Text = (lblcalculator.Text & 9) End Sub Private Sub Btn0_Click(sender As Object, e As EventArgs) Handles Btn0.Click lblcalculator.Text = (lblcalculator.Text & 0) End Sub Private Sub BtnPower_Click(sender As Object, e As EventArgs) Handles BtnPower.Click lblcalculator.Text = (lblcalculator.Text & "^") End Sub Private Sub BtnMultiply_Click(sender As Object, e As EventArgs) Handles BtnMultiply.Click lblcalculator.Text = (lblcalculator.Text & "*") End Sub Private Sub BtnDivision_Click(sender As Object, e As EventArgs) Handles BtnDivision.Click lblcalculator.Text = (lblcalculator.Text & "/") End Sub Private Sub BtnPlus_Click(sender As Object, e As EventArgs) Handles BtnPlus.Click lblcalculator.Text = (lblcalculator.Text & Chr(43)) End Sub Private Sub BtnMinus_Click(sender As Object, e As EventArgs) Handles BtnMinus.Click lblcalculator.Text = (lblcalculator.Text & "-") End Sub

[Pick the date]

27

CALCULATOR CODE

Private Sub btnIntegerDivision_Click(sender As Object, e As EventArgs) Handles btnIntegerDivision.Click lblcalculator.Text = (lblcalculator.Text & "\") End Sub Private Sub btnPara1_Click(sender As Object, e As EventArgs) Handles btnPara1.Click lblcalculator.Text = (lblcalculator.Text & "(") End Sub Private Sub btnPara2_Click(sender As Object, e As EventArgs) Handles btnPara2.Click lblcalculator.Text = (lblcalculator.Text & ")") End Sub Private Sub lblcalculator_Click(sender As Object, e As EventArgs) Handles lblcalculator.Click Process.Start("Notepad", "CalculatorHelp") End Sub Private Sub frmCalculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub

End Class

[Pick the date]

28

LOAN CALCULATOR CODE

Public Class frmLoanCalculator #Region "Loan Calculator" Private Sub BtnCL_Click(sender As Object, e As EventArgs) Handles BtnCL.Click txtPrincipal.Text = "" txtNumpayment.Text = "" txtInterest.Text = "" lblAmtPayments.Text = "" List_Amortization.Items.Clear() n = 0 End Sub Private Sub BtnCalPP_Click(sender As Object, e As EventArgs) Handles BtnCalPP.Click P = txtPrincipal.Text Year = txtNumpayment.Text Num = 12 * Year r = txtInterest.Text I = r / 100 PVIFA = Pmt(I / 12, Num, -P) lblAmtPayments.Text = Math.Round(PVIFA, 2) lblAmtPayments.Text = FormatCurrency(PVIFA, 2) txtPrincipal.Text = FormatCurrency(P, 2) End Sub Private Sub BtnCreateTable_Click(sender As Object, e As EventArgs) Handles BtnCreateTable.Click If lblAmtPayments.Text = "" Then Exit Sub List_Amortization.Items.Add("Month" & vbTab & vbTab & vbTab & "Interest" & vbTab & vbTab & "Principal" & vbTab & vbTab & "Balance") List_Amortization.Items.Add("Number" & vbTab & vbTab & vbTab & "Payment" & vbTab & vbTab & "Payment") List_Amortization.Items.Add("________________________________________________________________________________") n = 0 P = txtPrincipal.Text Do n = n + 1 PI = P * I / 12 PP = PVIFA - PI P = P - PP List_Amortization.Items.Add(n & vbTab & vbTab & vbTab & FormatCurrency(Math.Round(PI, 2)) & vbTab & vbTab & FormatCurrency(Math.Round(PP, 2)) & vbTab & vbTab & FormatCurrency(Math.Round(P, 2))) If n = Num Then Exit Do End If Loop End Sub Private Sub txtPrincipal_TextChanged(sender As Object, e As EventArgs) End Sub Private Sub txtPrincipal_LostFocus(sender As Object, e As EventArgs) If IsNumeric(txtPrincipal.Text) Then txtPrincipal.Text = FormatCurrency(txtPrincipal.Text) Else MessageBox.Show("Loan amount contains Letters, Format your Numbers") End If End Sub #End Region End Class

[Pick the date]

29

WORD PROCESSOR CODE

Imports System.Drawing.Font Imports System.Drawing.FontFamily Imports System.Drawing.FontConverter Imports System.Drawing.Printing Imports System.IO Public Class frmWordProcessor Private WithEvents PrintDoc As New PrintDialog Private WithEvents PreviewDialog As New PrintPreviewDialog Private WithEvents TempDocument As New PrintDocument Private TempPrintString As String = Nothing Dim filename As String = "" Public FontSizes() = {8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48} Dim dirty As Boolean Public Property performclick As Object Private Sub WordProcessor_Load(sender As Object, e As EventArgs) Handles Me.Load dirty = False tscbFontsize.Items.AddRange(FontSizes) tscbFontsize.SelectedText = (12) tscbFontsize.Text = (12) tscbFont.SelectedText = "Modern No. 20" tscbFont.Text = "Modern No. 20" Dim ff As FontFamily For Each ff In System.Drawing.FontFamily.Families tscbFont.Items.Add(ff.Name) Next End Sub Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles tsmiCopy.Click rtbDoc.Copy() End Sub Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles tsmiCut.Click rtbDoc.Cut() End Sub Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles tsmiPaste.Click rtbDoc.Paste() End Sub Private Sub FontToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles tsmiFont.Click FontDialog1.ShowDialog() rtbDoc.SelectionFont = FontDialog1.Font End Sub Private Sub ColorToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles tsmiColor.Click ColorDialog1.ShowDialog() rtbDoc.SelectionColor = ColorDialog1.Color End Sub Private Sub tsbBold_Click(sender As Object, e As EventArgs) Handles tsbBold.Click Dim style As FontStyle If rtbDoc.SelectionFont.Bold Then style = rtbDoc.SelectionFont.Style _ And Not FontStyle.Bold rtbDoc.SelectionFont = New Font(rtbDoc.SelectionFont, style)

[Pick the date]

30

WORD PROCESSOR CODE

Else style = rtbDoc.SelectionFont.Style _ Or FontStyle.Bold rtbDoc.SelectionFont = New Font(rtbDoc.SelectionFont, style) End If rtbDoc.Focus() End Sub Private Sub tsbItalics_Click(sender As Object, e As EventArgs) Handles tsbItalics.Click Dim style As FontStyle If rtbDoc.SelectionFont.Italic Then style = rtbDoc.SelectionFont.Style _ And Not FontStyle.Italic rtbDoc.SelectionFont = New Font(rtbDoc.SelectionFont, style) Else style = rtbDoc.SelectionFont.Style _ Or FontStyle.Italic rtbDoc.SelectionFont = New Font(rtbDoc.SelectionFont, style) End If rtbDoc.Focus() End Sub Private Sub tsbUnderline_Click(sender As Object, e As EventArgs) Handles tsbUnderline.Click Dim style As FontStyle If rtbDoc.SelectionFont.Underline Then style = rtbDoc.SelectionFont.Style _ And Not FontStyle.Underline rtbDoc.SelectionFont = New Font(rtbDoc.SelectionFont, style) Else style = rtbDoc.SelectionFont.Style _ Or FontStyle.Underline rtbDoc.SelectionFont = New Font(rtbDoc.SelectionFont, style) End If rtbDoc.Focus() End Sub Private Sub WORDPROCESSOR_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing checkdirty() End Sub Private Sub rtbDoc_TextChanged(sender As Object, e As EventArgs) Handles rtbDoc.TextChanged, rtbDoc.StyleChanged, rtbDoc.SizeChanged dirty = True End Sub Private Sub tscbFontsize_TextChanged(sender As Object, e As EventArgs) Handles tscbFontsize.TextChanged Try IsNumeric(tscbFontsize.Text) Catch ex As Exception MsgBox("FontSize must be Numeric.") End Try Dim newsize As Single = Convert.ToSingle(tscbFontsize.Text) rtbDoc.SelectionFont = New Font(rtbDoc.SelectionFont.FontFamily, newsize) End Sub Private Sub tsbInsertPic_Click(sender As Object, e As EventArgs) Handles tsbInsertPic.Click

[Pick the date]

31

WORD PROCESSOR CODE

OpenFileDialog1.Filter = "All Files|*.*" Dim photo As Image If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then photo = Image.FromFile(OpenFileDialog1.FileName) Clipboard.SetImage(photo) rtbDoc.Paste() End If End Sub Private Sub tsbInsertText_Click(sender As Object, e As EventArgs) Handles tsbInsertText.Click Dim mystream As IO.Stream = Nothing OpenFileDialog1.InitialDirectory = "c:\" OpenFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" OpenFileDialog1.FilterIndex = 1 OpenFileDialog1.RestoreDirectory = True If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Try mystream = OpenFileDialog1.OpenFile() If (mystream IsNot Nothing) Then rtbDoc.Text = rtbDoc.Text + My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName) End If Catch ex As Exception MsgBox("Cannot read file from disk. Original error: " & ex.Message) Finally If (mystream IsNot Nothing) Then mystream.Close() End If End Try End If End Sub Private Sub tsmiSaveAs_Click(sender As Object, e As EventArgs) Handles tsmiSaveAs.Click SaveFileDialog1.Filter = "All Files|*.*" If SaveFileDialog1.ShowDialog = DialogResult.OK Then 'savefile rtbDoc.SaveFile(SaveFileDialog1.FileName) dirty = False 'remeber filename filename = SaveFileDialog1.FileName 'change title to Me.Text = "Word Processor - " & IO.Path.GetFileName(filename) End If End Sub Private Sub tsmiExit_Click(sender As Object, e As EventArgs) Handles tsmiExit.Click checkdirty() Me.Close() End Sub Private Sub tsmiNew_Click(sender As Object, e As EventArgs) Handles tsmiNew.Click checkdirty() 'setup new Doc filename = "" dirty = False Me.Text = "Word Processor" rtbDoc.ResetText() End Sub

[Pick the date]

32

WORD PROCESSOR CODE

Private Sub checkdirty() If dirty = True Then If MessageBox.Show("Do you want to save Changes?", "Confirm", MessageBoxButtons.YesNo) = DialogResult.Yes Then tsmiSaveAs_Click(Nothing, Nothing) End If End If End Sub Private Sub tsmiSave_Click(sender As Object, e As EventArgs) Handles tsmiSave.Click If filename = "" Then tsmiSaveAs_Click(Nothing, Nothing) Else rtbDoc.SaveFile(filename) dirty = False End If End Sub Private Sub tsmiOpen_Click(sender As Object, e As EventArgs) Handles tsmiOpen.Click checkdirty() OpenFileDialog1.Filter = "All Files|*.*" If OpenFileDialog1.ShowDialog = DialogResult.OK Then rtbDoc.LoadFile(OpenFileDialog1.FileName) dirty = False filename = OpenFileDialog1.FileName Me.Text = "Word Processor - " & IO.Path.GetFileName(filename) End If End Sub Private Sub tscbFont_TextChanged(sender As Object, e As EventArgs) Handles tscbFont.TextChanged Dim fsize As Single = rtbDoc.SelectionFont.Size Dim newfont As String = tscbFont.Text rtbDoc.SelectionFont = New Font(newfont, fsize) End Sub Private Sub tsbAlignRight_Click(sender As Object, e As EventArgs) Handles tsbAlignleft.Click rtbDoc.SelectionAlignment = HorizontalAlignment.Left End Sub Private Sub tsbCenter_Click(sender As Object, e As EventArgs) Handles tsbCenter.Click rtbDoc.SelectionAlignment = HorizontalAlignment.Center End Sub Private Sub tsbJustify_Click(sender As Object, e As EventArgs) Handles tsbRightalign.Click rtbDoc.SelectionAlignment = HorizontalAlignment.Right End Sub Private Sub tsmiUndo_Click(sender As Object, e As EventArgs) Handles tsmiUndo.Click If rtbDoc.CanUndo Then rtbDoc.Undo() End If End Sub Private Sub tsbCopy_Click(sender As Object, e As EventArgs) Handles tsbCopy.Click tsmiCopy.PerformClick() End Sub Private Sub tsbCut_Click(sender As Object, e As EventArgs) Handles tsbCut.Click tsmiCut.PerformClick() End Sub Private Sub tsbPaste_Click(sender As Object, e As EventArgs) Handles tsbPaste.Click tsmiPaste.PerformClick() End Sub

[Pick the date]

33

WORD PROCESSOR CODE

Private Sub tsbPrintPreview_Click(sender As Object, e As EventArgs) Handles tsbPrintPreview.Click PreviewDialog.Name = "Print Preview" PreviewDialog.UseAntiAlias = True PreviewDialog.Document = TempDocument TempPrintString = rtbDoc.Text PreviewDialog.ShowDialog() PreviewDialog.Document = Nothing End Sub Private Sub tsbPrint_Click(sender As Object, e As EventArgs) Handles tsbPrint.Click TempPrintString = rtbDoc.Text TempDocument.Print() End Sub Private Sub TempDocument_PrintPage(sender As Object, e As PrintPageEventArgs) Handles TempDocument.PrintPage Dim charactersOnPage As Integer = 0 Dim linesPerPage As Integer = 0 e.Graphics.MeasureString(TempPrintString, New Font(rtbDoc.SelectionFont.FontFamily, rtbDoc.SelectionFont.Size, FontStyle.Regular), e.MarginBounds.Size, StringFormat.GenericTypographic, charactersOnPage, linesPerPage) e.Graphics.DrawString(TempPrintString, New Font(rtbDoc.SelectionFont.FontFamily, rtbDoc.SelectionFont.Size), Brushes.Black, e.MarginBounds, StringFormat.GenericTypographic) TempPrintString = TempPrintString.Substring(charactersOnPage) e.HasMorePages = TempPrintString.Length > 0 End Sub Private Sub tsmiPrint_Click(sender As Object, e As EventArgs) Handles tsmiPrint.Click tsbPrint.PerformClick() End Sub Private Sub tsmiPrintPreview_Click(sender As Object, e As EventArgs) Handles tsmiPrintPreview.Click tsbPrintPreview.PerformClick() End Sub Private Sub LeftToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LeftToolStripMenuItem.Click tsbAlignleft.PerformClick() End Sub Private Sub CenterToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CenterToolStripMenuItem.Click tsbCenter.PerformClick() End Sub Private Sub RightToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RightToolStripMenuItem.Click tsbRightalign.PerformClick() End Sub Private Sub tsmiRedo_Click(sender As Object, e As EventArgs) Handles tsmiRedo.Click If rtbDoc.CanRedo Then rtbDoc.Redo() End If End Sub Private Sub tsmiSelectAll_Click(sender As Object, e As EventArgs) Handles tsmiSelectAll.Click rtbDoc.SelectAll() End Sub Private Sub tsmiUpper_Click(sender As Object, e As EventArgs) Handles tsmiUpper.Click rtbDoc.SelectedText = rtbDoc.SelectedText.ToUpper

[Pick the date]

34

WORD PROCESSOR CODE

End Sub Private Sub HelpToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles HelpToolStripMenuItem1.Click Process.Start("Notepad", "help") End Sub Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click frmAboutBx.Show() End Sub End Class

[Pick the date]

35

LOGIN FORM CODE

Imports System.IO Imports System.Security.Cryptography Public Class FrmLogin Dim BadPass As Integer Private Sub frmlogin_load(sender As Object, e As EventArgs) Handles MyBase.Load UsernameTextBox.Text = ("Admin") End Sub Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Dim inputFile As StreamReader = File.OpenText("NotPasword.txt") Dim LinePW As String LinePW = inputFile.ReadLine() If BadPass = 0 Then BadPass = 1 End If If (UsernameTextBox.Text = "Admin") And (PasswordTextBox.Text = LinePW) Then frmInvpro.ShowDialog() Me.Close() Else MessageBox.Show("Incorrect Password! You have 3 login attempts," & vbCrLf & "This is attempt number " & BadPass, "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) BadPass += 1 End If If BadPass = 4 Then MessageBox.Show("You've exhausted your number of attempts", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Beep() Me.Close() End If End Sub Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click Me.Close() End Sub Private Sub LogoPictureBox_Click(sender As Object, e As EventArgs) Handles LogoPictureBox.Click frmInvpro.Show() Me.Close() End Sub End Class

[Pick the date]

36

TIC TAC TOE CODE

Public Class frmGame Dim random As String = 1 Private Sub TimerPic_Tick_1(sender As Object, e As EventArgs) random += 1 If random = 10 Then random = 1 End If

End Sub

Public Sub PC() If random = 1 And Button1.Enabled = True Then Button1.Text = "O" Button1.Enabled = False End If If random = 2 And Button2.Enabled = True Then Button2.Text = "O" Button2.Enabled = False End If If random = 3 And Button3.Enabled = True Then Button3.Text = "O" Button3.Enabled = False End If If random = 4 And Button4.Enabled = True Then Button4.Text = "O" Button4.Enabled = False End If If random = 5 And Button5.Enabled = True Then Button5.Text = "O" Button5.Enabled = False End If If random = 6 And Button6.Enabled = True Then Button6.Text = "O" Button6.Enabled = False End If If random = 7 And Button7.Enabled = True Then Button7.Text = "O" Button7.Enabled = False End If If random = 8 And Button8.Enabled = True Then Button8.Text = "O" Button8.Enabled = False End If If random = 9 And Button9.Enabled = True Then Button9.Text = "O" Button9.Enabled = False End If

End Sub

[Pick the date]

37

TIC TAC TOE CODE

Public Sub Options() 'If user hits 1 If Label1.Text = 1 Then If Button2.Text = "X" And Button3.Enabled = True Then With Button3 .Text = "O" .Enabled = False End With ElseIf Button3.Text = "X" And Button2.Enabled = True Then With Button2 .Text = "O" .Enabled = False End With ElseIf Button5.Text = "X" And Button9.Enabled = True Then With Button9 .Text = "O" .Enabled = False End With ElseIf Button9.Text = "X" And Button5.Enabled = True Then With Button5 .Text = "O" .Enabled = False End With ElseIf Button4.Text = "X" And Button7.Enabled = True Then With Button7 .Text = "O" .Enabled = False End With ElseIf Button7.Text = "X" And Button4.Enabled = True Then With Button4 .Text = "O" .Enabled = False End With ElseIf Button8.Text = "X" Or Button6.Text = "X" Then hit() End If End If 'If user hits 2 If Label1.Text = 2 Then If Button1.Text = "X" And Button3.Enabled = True Then With Button3 .Text = "O" .Enabled = False End With ElseIf Button1.Text = "X" And Button1.Enabled = True Then With Button1 .Text = "O" .Enabled = False End With ElseIf Button5.Text = "X" And Button8.Enabled = True Then With Button8 .Text = "O" .Enabled = False End With ElseIf Button8.Text = "X" And Button5.Enabled = True Then

[Pick the date]

38

TIC TAC TOE CODE

With Button5 .Text = "O" .Enabled = False End With ElseIf Button6.Text = "X" Or Button4.Text = "X" Or Button7.Text = "X" Or Button9.Text = "X" Then hit() End If End If 'If user hits 3 If Label1.Text = 3 Then If Button1.Text = "X" And Button2.Enabled = True Then With Button2 .Text = "O" .Enabled = False End With ElseIf Button2.Text = "X" And Button1.Enabled = True Then With Button1 .Text = "O" .Enabled = False End With ElseIf Button6.Text = "X" And Button9.Enabled = True Then With Button9 .Text = "O" .Enabled = False End With ElseIf Button9.Text = "X" And Button6.Enabled = True Then With Button6 .Text = "O" .Enabled = False End With ElseIf Button6.Text = "X" And Button9.Enabled = True Then With Button9 .Text = "O" .Enabled = False End With ElseIf Button5.Text = "X" And Button7.Enabled = True Then With Button7 .Text = "O" .Enabled = False End With ElseIf Button7.Text = "X" And Button5.Enabled = True Then With Button5 .Text = "O" .Enabled = False End With ElseIf Button8.Text = "X" Or Button4.Text = "X" Then hit() End If

End If

'If user hits 4 If Label1.Text = 4 Then If Button1.Text = "X" And Button7.Enabled = True Then

[Pick the date]

39

TIC TAC TOE CODE

With Button7 .Text = "O" .Enabled = False End With ElseIf Button7.Text = "X" And Button1.Enabled = True Then With Button1 .Text = "O" .Enabled = False End With ElseIf Button5.Text = "X" And Button6.Enabled = True Then With Button6 .Text = "O" .Enabled = False End With ElseIf Button6.Text = "X" And Button5.Enabled = True Then With Button5 .Text = "O" .Enabled = False End With ElseIf Button2.Text = "X" Or Button3.Text = "X" Or Button8.Text = "X" Or Button9.Text = "X" Then hit() End If End If 'If user hits 5 If Label1.Text = 5 Then If Button1.Text = "X" And Button9.Enabled = True Then With Button9 .Text = "O" .Enabled = False End With ElseIf Button9.Text = "X" And Button1.Enabled = True Then With Button1 .Text = "O" .Enabled = False End With ElseIf Button2.Text = "X" And Button8.Enabled = True Then With Button8 .Text = "O" .Enabled = False End With ElseIf Button8.Text = "X" And Button2.Enabled = True Then With Button2 .Text = "O" .Enabled = False End With ElseIf Button3.Text = "X" And Button7.Enabled = True Then With Button7 .Text = "O" .Enabled = False End With ElseIf Button7.Text = "X" And Button3.Enabled = True Then With Button3 .Text = "O" .Enabled = False

[Pick the date]

40

TIC TAC TOE CODE

End With ElseIf Button6.Text = "X" And Button4.Enabled = True Then With Button4 .Text = "O" .Enabled = False End With ElseIf Button4.Text = "X" And Button6.Enabled = True Then With Button6 .Text = "O" .Enabled = False End With End If End If 'If user hits 6 If Label1.Text = 6 Then If Button3.Text = "X" And Button9.Enabled = True Then With Button9 .Text = "O" .Enabled = False End With ElseIf Button9.Text = "X" And Button3.Enabled = True Then With Button3 .Text = "O" .Enabled = False End With ElseIf Button5.Text = "X" And Button4.Enabled = True Then With Button4 .Text = "O" .Enabled = False End With ElseIf Button4.Text = "X" And Button5.Enabled = True Then With Button5 .Text = "O" .Enabled = False End With ElseIf Button1.Text = "X" Or Button2.Text = "X" Or Button7.Text = "X" Or Button8.Text = "X" Then hit() End If End If 'If user hits 7 If Label1.Text = 7 Then If Button1.Text = "X" And Button4.Enabled = True Then With Button4 .Text = "O" .Enabled = False End With ElseIf Button4.Text = "X" And Button1.Enabled = True Then With Button1 .Text = "O" .Enabled = False End With ElseIf Button5.Text = "X" And Button3.Enabled = True Then With Button3 .Text = "O"

[Pick the date]

41

TIC TAC TOE CODE

.Enabled = False End With ElseIf Button3.Text = "X" And Button5.Enabled = True Then With Button5 .Text = "O" .Enabled = False End With ElseIf Button8.Text = "X" And Button9.Enabled = True Then With Button9 .Text = "O" .Enabled = False End With ElseIf Button9.Text = "X" And Button8.Enabled = True Then With Button8 .Text = "O" .Enabled = False End With ElseIf Button6.Text = "X" Or Button2.Text = "X" Then hit() End If End If 'If user hits 8 If Label1.Text = 8 Then If Button2.Text = "X" And Button5.Enabled = True Then With Button5 .Text = "O" .Enabled = False End With ElseIf Button5.Text = "X" And Button2.Enabled = True Then With Button2 .Text = "O" .Enabled = False End With ElseIf Button9.Text = "X" And Button7.Enabled = True Then With Button7 .Text = "O" .Enabled = False End With ElseIf Button7.Text = "X" And Button9.Enabled = True Then With Button9 .Text = "O" .Enabled = False End With ElseIf Button6.Text = "X" Or Button3.Text = "X" Or Button1.Text = "X" Or Button4.Text = "X" Then hit() End If End If 'If user hits 9 If Label1.Text = 9 Then If Button6.Text = "X" And Button3.Enabled = True Then With Button3 .Text = "O" .Enabled = False End With

[Pick the date]

42

TIC TAC TOE CODE

ElseIf Button3.Text = "X" And Button6.Enabled = True Then With Button6 .Text = "O" .Enabled = False End With ElseIf Button5.Text = "X" And Button1.Enabled = True Then With Button1 .Text = "O" .Enabled = False End With ElseIf Button1.Text = "X" And Button5.Enabled = True Then With Button5 .Text = "O" .Enabled = False End With ElseIf Button8.Text = "X" And Button7.Enabled = True Then With Button7 .Text = "O" .Enabled = False End With ElseIf Button7.Text = "X" And Button8.Enabled = True Then With Button8 .Text = "O" .Enabled = False End With ElseIf Button2.Text = "X" Or Button4.Text = "X" Then hit() End If End If

End Sub

Public Sub CheckIfComputerWins() If Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" _ Or Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" _ Or Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" _ Or Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" _ Or Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" _ Or Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" _ Or Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" _ Or Button7.Text = "O" And Button5.Text = "O" And Button3.Text = "O" Then MsgBox("Computer Wins") Button1.Text = "" Button1.Enabled = True Button2.Text = "" Button2.Enabled = True Button3.Text = "" Button3.Enabled = True Button4.Text = "" Button4.Enabled = True Button5.Text = "" Button5.Enabled = True Button6.Text = "" Button6.Enabled = True Button7.Text = ""

[Pick the date]

43

TIC TAC TOE CODE

Button7.Enabled = True Button8.Text = "" Button8.Enabled = True Button9.Text = "" Button9.Enabled = True random = 1 ElseIf Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" _ Or Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" _ Or Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" _ Or Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" _ Or Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" _ Or Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" _ Or Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" _ Or Button7.Text = "X" And Button5.Text = "X" And Button3.Text = "X" Then MsgBox("Congratulations, You Win") Button1.Text = "" Button1.Enabled = True Button2.Text = "" Button2.Enabled = True Button3.Text = "" Button3.Enabled = True Button4.Text = "" Button4.Enabled = True Button5.Text = "" Button5.Enabled = True Button6.Text = "" Button6.Enabled = True Button7.Text = "" Button7.Enabled = True Button8.Text = "" Button8.Enabled = True Button9.Text = "" Button9.Enabled = True random = 1 End If End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Button9.Click, Button8.Click, Button7.Click, Button6.Click, Button5.Click, Button4.Click, Button3.Click, Button2.Click, Button1.Click sender.Text = "X" sender.Enabled = False Timer1.Stop() Label1.Text = sender.name Label1.Text = Label1.Text.Replace("Button", "") If random = Label1.Text Then random = random + 1 End If If random > 0 Then PC() random = 0 ElseIf random = 0 Then Options() End If Label2.Text = random CheckIfComputerWins()

[Pick the date]

44

TIC TAC TOE CODE

End Sub Public Sub hit() For Each ctl As Control In Me.Controls If Label1.Text < 9 Then If (ctl.Name.StartsWith("Button" & Label1.Text + 1)) Then Dim btn As Button = DirectCast(ctl, Button) If btn.Enabled = True Then btn.Text = "O" btn.Enabled = False Else Label1.Text = Label1.Text + 1 End If End If Else If (ctl.Name.StartsWith("Button1")) Then Dim btn As Button = DirectCast(ctl, Button) If btn.Enabled = True Then btn.Text = "O" btn.Enabled = False Else Label1.Text = Label1.Text + 1 End If End If End If Next End Sub Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click Timer1.Stop() Button1.Text = "O" Label1.Text = 1 Button1.Enabled = False Button10.Enabled = False End Sub Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click Button1.Text = "" Button1.Enabled = True Button2.Text = "" Button2.Enabled = True Button3.Text = "" Button3.Enabled = True Button4.Text = "" Button4.Enabled = True Button5.Text = "" Button5.Enabled = True Button6.Text = "" Button6.Enabled = True Button7.Text = "" Button7.Enabled = True Button8.Text = "" Button8.Enabled = True Button9.Text = "" Button9.Enabled = True Button10.Enabled = True

[Pick the date]

45

TIC TAC TOE CODE

Timer1.Start() random = 1 End Sub Private Sub Button10_TextChanged(sender As Object, e As EventArgs) Handles Button10.TextChanged Button11.Enabled = True Button11.Text = "Restart" Button10.Text = "PC Start" End Sub Private Sub frmGame_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub

End Class