VERSION 5.00 Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX" Begin VB.Form Form1 BackColor = &H00FFFF80& Caption = "CONCENTRATION" ClientHeight = 7140 ClientLeft = 1170 ClientTop = 2250 ClientWidth = 10965 LinkTopic = "Form1" ScaleHeight = 7140 ScaleWidth = 10965 WindowState = 2 'Maximized Begin VB.CommandButton OK Caption = "OK" Height = 615 Left = 2160 TabIndex = 21 Top = 2880 Width = 495 End Begin VB.TextBox Text3 Height = 375 Left = 2160 TabIndex = 20 Top = 5880 Width = 495 End Begin VB.TextBox Text2 Height = 375 Left = 2160 TabIndex = 18 Top = 4680 Width = 495 End Begin VB.TextBox Text1 Height = 495 Left = 1920 MultiLine = -1 'True TabIndex = 15 Top = 2160 Width = 975 End Begin VB.PictureBox smile Height = 615 Left = 240 Picture = "ConCode.frx":0000 ScaleHeight = 555 ScaleWidth = 555 TabIndex = 14 Top = 4800 Visible = 0 'False Width = 615 End Begin VB.PictureBox Blank Height = 615 Left = 120 ScaleHeight = 555 ScaleWidth = 675 TabIndex = 13 Top = 4800 Visible = 0 'False Width = 735 End Begin VB.PictureBox tom Height = 855 Left = 120 Picture = "ConCode.frx":030A ScaleHeight = 795 ScaleWidth = 795 TabIndex = 12 Top = 4800 Visible = 0 'False Width = 855 End Begin VB.PictureBox todd Height = 855 Left = 0 Picture = "ConCode.frx":0921 ScaleHeight = 795 ScaleWidth = 795 TabIndex = 11 Top = 4680 Visible = 0 'False Width = 855 End Begin VB.PictureBox miken Height = 855 Left = 120 Picture = "ConCode.frx":10D3 ScaleHeight = 795 ScaleWidth = 795 TabIndex = 10 Top = 4800 Visible = 0 'False Width = 855 End Begin VB.PictureBox mikea Height = 855 Left = 120 Picture = "ConCode.frx":1846 ScaleHeight = 795 ScaleWidth = 795 TabIndex = 9 Top = 4680 Visible = 0 'False Width = 855 End Begin VB.PictureBox kevin Height = 855 Left = 0 Picture = "ConCode.frx":1FE4 ScaleHeight = 795 ScaleWidth = 795 TabIndex = 8 Top = 4560 Visible = 0 'False Width = 855 End Begin VB.PictureBox jeff Height = 855 Left = 120 Picture = "ConCode.frx":2839 ScaleHeight = 795 ScaleWidth = 795 TabIndex = 7 Top = 4560 Visible = 0 'False Width = 855 End Begin VB.PictureBox matt Height = 855 Left = 0 Picture = "ConCode.frx":305F ScaleHeight = 795 ScaleWidth = 795 TabIndex = 6 Top = 4680 Visible = 0 'False Width = 855 End Begin VB.PictureBox jason Height = 855 Left = 120 Picture = "ConCode.frx":37BA ScaleHeight = 795 ScaleWidth = 795 TabIndex = 5 Top = 4560 Visible = 0 'False Width = 855 End Begin VB.PictureBox corey Height = 855 Left = 120 Picture = "ConCode.frx":3F2A ScaleHeight = 795 ScaleWidth = 795 TabIndex = 4 Top = 4800 Visible = 0 'False Width = 855 End Begin VB.PictureBox bryan Height = 855 Left = 120 Picture = "ConCode.frx":45BE ScaleHeight = 795 ScaleWidth = 795 TabIndex = 3 Top = 4800 Visible = 0 'False Width = 855 End Begin VB.PictureBox brad Height = 855 Left = 0 Picture = "ConCode.frx":4C5D ScaleHeight = 795 ScaleWidth = 795 TabIndex = 2 Top = 4680 Visible = 0 'False Width = 855 End Begin VB.PictureBox bill Height = 855 Left = 0 Picture = "ConCode.frx":5407 ScaleHeight = 795 ScaleWidth = 795 TabIndex = 1 Top = 4680 Visible = 0 'False Width = 855 End Begin MSFlexGridLib.MSFlexGrid grdTable Height = 4935 Left = 3960 TabIndex = 0 Top = 1560 Width = 6495 _ExtentX = 11456 _ExtentY = 8705 _Version = 393216 Rows = 6 Cols = 8 FixedRows = 0 FixedCols = 0 BackColor = 12648447 End Begin VB.Label Label4 BackColor = &H00FFFF80& Caption = "CONCENTRATION" BeginProperty Font Name = "Comic Sans MS" Size = 33.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 1215 Left = 4080 TabIndex = 22 Top = 240 Width = 6615 End Begin VB.Label Label3 Height = 255 Left = 1920 TabIndex = 19 Top = 5280 Width = 975 End Begin VB.Label Label2 Height = 255 Left = 1920 TabIndex = 17 Top = 4200 Width = 975 End Begin VB.Label Label1 Alignment = 2 'Center Caption = "Score" Height = 255 Left = 2040 TabIndex = 16 Top = 3720 Width = 735 End Begin VB.Menu Game Caption = "Game" Begin VB.Menu New Caption = "New" End Begin VB.Menu About Caption = "About" End Begin VB.Menu Exit Caption = "Exit" End End Begin VB.Menu Help Caption = "Help" Begin VB.Menu Instuctions Caption = "Instructions" End Begin VB.Menu Solution Caption = "Solution" Enabled = 0 'False End End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim x As Integer 'denotes which picture, 1-12 Dim A(48) As Integer 'our array storing 1-48 randomly Dim PT As Integer 'denotes Player's Turn, either 1 or 2 Dim NT As Integer 'denotes # of turns Dim Player1 As String 'Name of player 1 Dim Player2 As String 'Name of player 2 Dim Guess1 As String 'name of person 1 picked Dim Guess2 As String 'name of person 2 picked Dim OPR As Integer 'old picture row Dim OPC As Integer 'old picture column Dim NPR As Integer 'new picture row Dim NPC As Integer 'new picture column Dim PR As Integer 'current picture row Dim PC As Integer 'cirrent picture column Dim P As Integer 'denotes location in array A() Dim R As Integer 'row Dim C As Integer 'column Private Sub About_Click() MsgBox "This game is brought to you by Berlin High School's Visual BASIC Programming class. We hope you enjoy it! Feel free to check out our home page at http://www.ncia.net/schools/berlin." End Sub Private Sub Exit_Click() MsgBox "Thank you for playing our game!" End End Sub Private Sub Form_Load() SetColWidth SetRowHeight CreateArrayA grdTable.Enabled = False OK.Enabled = False Text1.Enabled = False Text2.Enabled = False Text3.Enabled = False End Sub Public Sub SetColWidth() Dim counter For counter = 0 To 7 Step 1 grdTable.ColWidth(counter) = 800 Next counter End Sub Public Sub SetRowHeight() Dim counter For counter = 0 To 5 Step 1 grdTable.RowHeight(counter) = 800 Next counter End Sub Public Sub CreateArrayA() For x = 1 To 48 A(x) = x Next x End Sub Private Sub grdTable_Click() PR = grdTable.Row PC = grdTable.Col If grdTable.CellPicture = Blank.Picture Then If NT = 0 Then Guess1 = "" Guess2 = "dummy" End If NT = NT + 1 PR = grdTable.Row PC = grdTable.Col P = 8 * PR + (PC + 1) If A(P) / 4 = Int(A(P) / 4) Then x = A(P) / 4 Else x = Int(A(P) / 4) + 1 End If Select Case x Case 1 Set grdTable.CellPicture = bill.Picture If NT = 1 Then Guess1 = "bill" OPR = PR OPC = PC Else Guess2 = "bill" NPR = PR NPC = PC End If Case 2 Set grdTable.CellPicture = brad.Picture If NT = 1 Then Guess1 = "brad" OPR = PR OPC = PC Else Guess2 = "brad" NPR = PR NPC = PC End If Case 3 Set grdTable.CellPicture = bryan.Picture If NT = 1 Then Guess1 = "bryan" OPR = PR OPC = PC Else Guess2 = "bryan" NPR = PR NPC = PC End If Case 4 Set grdTable.CellPicture = jeff.Picture If NT = 1 Then Guess1 = "jeff" OPR = PR OPC = PC Else Guess2 = "jeff" NPR = PR NPC = PC End If Case 5 Set grdTable.CellPicture = mikea.Picture If NT = 1 Then Guess1 = "mikea" OPR = PR OPC = PC Else Guess2 = "mikea" NPR = PR NPC = PC End If Case 6 Set grdTable.CellPicture = todd.Picture If NT = 1 Then Guess1 = "todd" OPR = PR OPC = PC Else Guess2 = "todd" NPR = PR NPC = PC End If Case 7 Set grdTable.CellPicture = corey.Picture If NT = 1 Then Guess1 = "corey" OPR = PR OPC = PC Else Guess2 = "corey" NPR = PR NPC = PC End If Case 8 Set grdTable.CellPicture = jason.Picture If NT = 1 Then Guess1 = "jason" OPR = PR OPC = PC Else Guess2 = "jason" NPR = PR NPC = PC End If Case 9 Set grdTable.CellPicture = matt.Picture If NT = 1 Then Guess1 = "matt" OPR = PR OPC = PC Else Guess2 = "matt" NPR = PR NPC = PC End If Case 10 Set grdTable.CellPicture = kevin.Picture If NT = 1 Then Guess1 = "kevin" OPR = PR OPC = PC Else Guess2 = "kevin" NPR = PR NPC = PC End If Case 11 Set grdTable.CellPicture = miken.Picture If NT = 1 Then Guess1 = "miken" OPR = PR OPC = PC Else Guess2 = "miken" NPR = PR NPC = PC End If Case 12 Set grdTable.CellPicture = tom.Picture If NT = 1 Then Guess1 = "tom" OPR = PR OPC = PC Else Guess2 = "tom" NPR = PR NPC = PC End If End Select If Guess1 = Guess2 And PT = 1 Then Text2.Text = Val(Text2.Text) + 1 NT = 0 grdTable.Enabled = False OK.Enabled = True ElseIf Guess1 = Guess2 And PT = 2 Then Text3.Text = Val(Text3.Text) + 1 NT = 0 grdTable.Enabled = False OK.Enabled = True ElseIf Guess1 <> Guess2 And PT = 1 And NT = 2 Then NT = 0 PT = 2 Text1.Text = Player2 & "'s turn" grdTable.Enabled = False OK.Enabled = True ElseIf Guess1 <> Guess2 And PT = 2 And NT = 2 Then NT = 0 PT = 1 Text1.Text = Player1 & "'s turn" grdTable.Enabled = False OK.Enabled = True End If End If End Sub Private Sub Instuctions_Click() MsgBox "Welcome to Concentration! Select New under Game and enter your names. Try to find pairs of matching pictures by clicking on the cells. Click the OK button after selecting two different cells. If you make a match, you get another turn. The person with the most matches wins." End Sub Private Sub New_Click() OK.Enabled = False Solution.Enabled = True For R = 0 To 5 For C = 0 To 7 grdTable.Row = R grdTable.Col = C Set grdTable.CellPicture = Blank.Picture Next C Next R Shuffle Player1 = InputBox("Player 1, what is your name?", "Player1", "Player1") Label2.Caption = Player1 Player2 = InputBox("Player 2, what is your name?", "Player2", "Player2") Label3.Caption = Player2 PT = 1 NT = 0 Text2.Text = 0 Text3.Text = 0 Text1.Text = Player1 & "'s turn" grdTable.Enabled = True End Sub Public Sub Shuffle() Randomize Dim S As Integer Dim H As Integer For x = 48 To 2 Step -1 S = Int(Rnd * 48 + 1) H = A(x) A(x) = A(S) A(S) = H Next x End Sub Private Sub OK_Click() If Guess1 = Guess2 Then grdTable.Row = OPR grdTable.Col = OPC Set grdTable.CellPicture = smile.Picture grdTable.Row = NPR grdTable.Col = NPC Set grdTable.CellPicture = smile.Picture grdTable.Enabled = True Else grdTable.Row = OPR grdTable.Col = OPC Set grdTable.CellPicture = Blank.Picture grdTable.Row = NPR grdTable.Col = NPC Set grdTable.CellPicture = Blank.Picture grdTable.Enabled = True End If OK.Enabled = False If Val(Text2.Text) + Val(Text3.Text) = 24 Then If Val(Text2.Text) > Val(Text3.Text) Then MsgBox Player1 & " wins!" ElseIf Val(Text2.Text) < Val(Text3.Text) Then MsgBox Player2 & " wins!" Else MsgBox "It's a tie!" End If End If End Sub Private Sub Solution_Click() For P = 1 To 48 If P / 8 = Int(P / 8) Then grdTable.Row = P / 8 - 1 Else grdTable.Row = Int(P / 8) End If grdTable.Col = P - (grdTable.Row * 8) - 1 If A(P) / 4 = Int(A(P) / 4) Then x = A(P) / 4 Else x = Int(A(P) / 4) + 1 End If Select Case x Case 1 Set grdTable.CellPicture = bill.Picture Case 2 Set grdTable.CellPicture = brad.Picture Case 3 Set grdTable.CellPicture = bryan.Picture Case 4 Set grdTable.CellPicture = jeff.Picture Case 5 Set grdTable.CellPicture = mikea.Picture Case 6 Set grdTable.CellPicture = todd.Picture Case 7 Set grdTable.CellPicture = corey.Picture Case 8 Set grdTable.CellPicture = jason.Picture Case 9 Set grdTable.CellPicture = matt.Picture Case 10 Set grdTable.CellPicture = kevin.Picture Case 11 Set grdTable.CellPicture = miken.Picture Case 12 Set grdTable.CellPicture = tom.Picture End Select Next P End Sub