Part 2: A wee game for AoifeNiBrian

Day 2,749, 04:17 Published in Ireland Ireland by Releasethe Krakken


So I assume our Aoife is a fan. Tried to deduce the meaning of her name. Anyway to continue.

The game is completed. I didnt really work as hard on it but it shows many of the techniques we regularly use is displayed.

Anyway here is new form



Ok the entry textboxes follows the following naming convention:

txt - the standard way of reffering to a textbox
US - for user selection
A to E for the row numbers
and 1 to 10 for the column number

therefore txtUSA1 to txtUSA10
......
txtUSE1 to txtUSE10

its important to follow this convention exactly as we are going to use their name length to work on them later.

the small textboxes indicating results have the following naming conventions
txt - as explained
Indi - for indicator
A to E for the row numbers
and 1 to 10 for the column numbers
therefore txtIndiA1 to txtIndiA10
.....
txtIndiE1 to txtIndiE10

the backcolors to better show individual columns is
whitesmoke, palegoldenrod,wheat, tan,palegreen,lightsalmon,orange,thistle,plum, systemcolors.highlight

Below I added a legend with colors and corresponding numbers
using labels
naming convention lbllegend1 to lbllegend10 and lbldelete to the end .

Beside that is lblselectedcolor to store selected colors

to the left bottom is a checkbox called chkmouse to let the user choose enter manual keyboard input or mouse selection.

the submit buttons was called btnsubmitA to btnsubmite
the row number indicators which is labels lblrowA to lblRowE

below each column a small label with borderstyle fixed3d was added to help the user identify the cell selected to the top is a similar label.

As we are not using this is code it was not named.

To the top we have the up button btnup

with backgroundimage of a sky and font webdings size 26 and entered text 5.

Above that the code textboxes named txtSecretcode1 to txtSecretCode10

besides that is victory indicators. Which is 2 panels with backcolor red I created 2 buttons besides that. I found the pic searching for bullet pics in google. I saved it to computer and used the resize button in paint to reduce the size of the original pic to fit my panel. I selected the panel and pasted the button in it. The button then belongs to the panel and cannot be moved outside the panel(its container control or the control in which it is contained). i set the panels named pnlboom and pnlboom2 visible to false.

I then went to the Project tab and then added a new windows form. It is the convention to not name forms or anyway my convention.

I resized it to the same size as the first form and copied the panel where most controls is contained in to the new form. I then copy/pasted all the other controls to the new form. They kept their names which is why one usually keep stuff in a panel.

I also copied the mainmenu but changed the command in exit to me.close added a new tab and will add end in that one perhaps call it close program.

one cannot close form 1 without closing the entire program thats why one uses a second form.

I think the naming conventions is luckily over now and I can share the code


THE CODE

Creating the secret code



Basically it uses the randomize system function to create a new number between 0 and 9. It uses for to create 10 numbers and add it to the TheCode global variable. the for construct uses for from to number and next to cycle to the next x number. One can use step to even count downwards in the form step -1 .

I also added a module(using the project tab) called GlobalVariables where i declared
Public TheCode as String

You will also see I used Clearvalues() which is a call to the sub routine to setup the form for a new game.

I furthemore commented the messagebox.show(thecode) out. When i tested the code I used this to show me what the ocde is.

Its important that your code does the correct thing therefore run it a few times and text the vales for accuracy before finishing it.

Clearvalues is a long sub so I give it in 2 pics





Clearvalues cycle through all the controls to check for a textbox that has name length 7 or 8 the user selection textboxes.

if length = 7 1 digit is returned 1 to 9 if 8 2 digits is returned therefore 10

All userslection boxes is set to readonly = true and text value ""

I then use a select construct to chose between various values to assign the correct backcolor to each user selection textbox.

rowname is the number of the column 1 to 10

I also check for the indicator checkboxes and reset their backcolors to whitemsoke . that is the if x.length = 9 or 10 bit

Finally I set the readonly value of the first row to false.

By doing this I contraint the user to only chose the first block. But he may still use the mouse to make selections. in hindsight it would be better to disable all user selection textboxes after we submitted our text answer.

Anyway that concludes Part 2

I will submit the other final part later. It is a lot of code.

If your bored by now. Yeah programming is very boring if you don follow it. But then again you can :

Run to the hills...

Part 1: http://www.erepublik.com/en/article/a-wee-game-for-aoinf-or-anyone-who-cares-2526788/1/20
Part 2: http://www.erepublik.com/en/main/edit-article/part-2-a-wee-game-for-aoifenibrian-2527675


Dream of mirrors
Hallowed be thy name