Two questions...

11-09-2001, 06:29 PM
I know it has been awhile since I've been here (and yes, I'm still working at an RPG), but I have two questions on two smaller projects I'm working on for fun (sort of)

First of all, I'm making a sort of elementary level math program, and I have it essentially working fine except that I can't remember how to make VB divide and give a remainder instead of a decimal (that way I can make sure it picks random numbers that give integer answers instead of decimal)

Now for my next question...
I have been tasked with creating a sort of 'matching game' (the type where you have so many things that you flip over, click on, whatever and make matches, then continue), and I am having a few problems.

First of all, how would you recommend that I go about creating this (in regards to setting the pictures to the buttons, or whatever), and how would I tell it to 'scramble' the images or whatever. The second part is the one I am focusing the most on, because I've never quite been able to work out that little problem before...

11-09-2001, 07:33 PM
In order to divide two numbers and get the integer remainder, use the MOD function. The syntax is as follows:

result = number1 Mod number2

For example, the function 11 MOD 3 would give you 2, because 11 divided by 3 is 3 remainder 2.

11-09-2001, 10:09 PM
Ahh...That is what it was...thanks.. Now, does anyone have any suggestions for my second question?

wild wolf
11-09-2001, 10:32 PM
hmm, r u making a game something like all cards are turned facing down and the user clicks on cards to get similar cards to match them right? if thats the case, lets say u have 8 cards (four pairs, when a player starts, the location of these cards are set to random using the random function and when a player clicks on it the upside down pic is set to visible false and the face is set to visible true, u could make the game hard by making some games unsolvable
if this is not what ur doind then discard this post as void

11-09-2001, 10:53 PM
That's what I'm doing, but I'm really not following you...

This is what I was PLANNING on doing...

Let's say I have 10 buttons (I will use more than that, and that is assuming that buttons will work for this). I either want to assign each a random picture (not visible of course) when the program loads, or have fixed pictures, but buttons that arrange themselves in a random order when the program loads.

This is the first problem I do I do this? I can make random numbers with no difficulty, but I've never learned how to randomize entire sets of things...

After the program loads, I want the user to be able to click on a button, at which point the picture will display, and that button will disable, or whatever it takes for it to not function... I'm sure this wouldn't be a problem for me, but since you all have a LOT more experience than I do, how would you suggest I do this? (I tend to take the more difficult paths when I often don't have to...)

And finally, what should I do about the victory conditions, as in, how do I recognize when two pictures are the same?

wild wolf
11-10-2001, 03:45 AM
store the pics in an array, lets say u have 10 total to play with (5 pairs), store them in an array and u check whether the two clicked are the same (check with the array number), if they are the same then increase the score value and disable the button.if they do not match then set the images to visible false and then leave the button able.

11-10-2001, 02:07 PM
I'm trying to teach myself VB one step at a time...could you perhaps spell that out with examples or steps?

wild wolf
11-11-2001, 03:37 AM
create a picture array, say 5 of them, create another picture array, 5 of them, with the same pic as the first five array (lets call the first array, pic1 and the second array pic2), set them all vivible false. When a user clicks on it lets say on the first pic, the array index is 1, and with the second click lets say he clicked on array index 4 of pic2, the index do not match, that means no points awarded and the pictures are set to visible false again, ok now try 2, the user clicks on array index 4 of pic1 and clicks on array index 4 of pic2, the indexes match, SCORE!! and it goes on. if u stiil dun get it, ill write for u a small program to demonstrate it

11-11-2001, 08:23 AM
Ahh...I see what you are saying now, but late last night I took a longer, and much more difficult works though.

I have 36 command buttons (with the images set to the DisabledPicture property), and these are set in a 6x6 area on the form. How can I make these rearrange when the form loads?

wild wolf
11-11-2001, 08:38 AM
thats quite easy if iam not mistaken, the value for the lets say and Button.left is set from another integer that is randomly generated using the random function, in this way the location is randomly generated evrytime the form loads, what do u say about that?

11-11-2001, 10:24 AM
That might work, but I'm confused... If you only use random integers, then isn't there the possibility that more than one button could get the same integer value, and thus, appear at the same place on the form?

wild wolf
11-11-2001, 11:04 AM
yeah that can be a problem too, but u can put a check on it, u create the number and after that it will store the same integer in another integer lets say called temp, after that it will check if temo exists with every number generated, it checks with the temp, if its equal then the number is regenerated and if it does not, it will go ahead and assign that number to temp

11-12-2001, 02:40 AM
here's a little code I use for shuffling a deck of cards, first preload the array with numbers 1 to 52, then use the following code to swap the values around

<font color=blue>For</font color=blue> i = 1 to 52
<font color=blue>Next</font color=blue> i
<font color=blue>For</font color=blue> i = 1 to 52
<font color=blue>Next</font color=blue> i

so instead of moving your buttons around you can stick your pictures in an imagelist and store the index
numbers in an array of integers (intDeck) and use some code like this to set the picture
<pre><font color=blue>Private Sub</font color=blue> Command1_Click(Index <font color=blue>As Integer</font color=blue>)

Command1(Index).Picture = ImageList1.ListImages(intDeck(Index)).Picture

<font color=blue>End Sub</font color=blue>

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum