How many Debug.Print statements do you have in the program and where are they?
Printable View
How many Debug.Print statements do you have in the program and where are they?
Now that you mention it, I know they are located in the ShuffleRed(/Blue)Cards subs. After doing a find on the Debug.Print, there are only two such lines and they appear in both ShuffleRedCards and ShuffleBlueCards subs.
I just put a breakpoint on the line just below the "Dim ___ As Integer, etc." line, and the call stack showed this:
CSEE.CS1.ShuffleBlueCards
CSEE.CS1.Form_Load
I did do a test run last weekend with technorobbo's copy, and there were still 2 decks of cards involved but in one Shuffle sub. So odds are, maybe it's possible that only one Shuffle sub may be needed, but has to be in the same form.
Although I did try that in the form or the GameEssentials6 module, and all I ended up with in the display window was all the cards being 2 of Spades.
I can send you both technorobbo's version along with mine later on if you wish, and you can compare both versions to notice the difference.
Without seeing your current code I'm guessing, but I'm pretty sure that you don't have more than two decks. You may be shuffling more than you think you are and if that's the case then that's why it looks like you have >2 decks.
And as to one or two shuffle subs, you need two shuffle subs if the red and blue decks can run out of cards at different times and I assume that that is what can happen.
I'm only shuffling more than I think because I am using a total of 104 cards (in 2 decks) during the first test run. But all subsequent test runs after that go beyond 104 cards.
I copied and pasted the sequence from both the first test run and the second test run onto a Microsoft Word document, and numerated them.
Here is the sequence from the first test run:And here is the sequence from the second test run:
- 2 of Diamonds
- 9 of Hearts
- 8 of Spades
- 7 of Clubs
- 4 of Spades
- Ace of Hearts
- 5 of Diamonds
- 2 of Clubs
- Queen of Hearts
- 6 of Clubs
- Ace of Spades
- 10 of Hearts
- 5 of Spades
- Queen of Clubs
- 10 of Clubs
- 6 of Diamonds
- 7 of Hearts
- 8 of Clubs
- 3 of Diamonds
- 3 of Spades
- 2 of Spades
- 9 of Diamonds
- Jack of Clubs
- 10 of Spades
- 6 of Hearts
- King of Diamonds
- Jack of Spades
- Queen of Diamonds
- King of Spades
- Ace of Clubs
- 5 of Hearts
- 8 of Hearts
- 4 of Diamonds
- King of Hearts
- 7 of Diamonds
- 4 of Hearts
- Ace of Diamonds
- Jack of Hearts
- 9 of Clubs
- Jack of Diamonds
- 6 of Spades
- 10 of Diamonds
- 5 of Clubs
- 3 of Clubs
- 7 of Spades
- 9 of Spades
- King of Clubs
- 3 of Hearts
- 8 of Diamonds
- 4 of Clubs
- Queen of Spades
- 2 of Hearts
- King of Clubs
- 6 of Clubs
- Jack of Diamonds
- 7 of Spades
- 3 of Clubs
- 10 of Clubs
- 4 of Hearts
- 3 of Hearts
- Jack of Hearts
- 9 of Spades
- Queen of Clubs
- Queen of Hearts
- Ace of Hearts
- 5 of Hearts
- Ace of Spades
- 5 of Diamonds
- 5 of Clubs
- 4 of Diamonds
- 8 of Spades
- Jack of Clubs
- 3 of Diamonds
- 4 of Clubs
- 3 of Spades
- 7 of Clubs
- 10 of Spades
- 8 of Diamonds
- Queen of Diamonds
- 8 of Clubs
- 8 of Hearts
- 6 of Hearts
- Ace of Diamonds
- 6 of Diamonds
- 9 of Clubs
- Queen of Spades
- King of Diamonds
- 10 of Hearts
- 5 of Spades
- 2 of Hearts
- 2 of Clubs
- 7 of Diamonds
- 6 of Spades
- 4 of Spades
- 9 of Diamonds
- 9 of Hearts
- 2 of Spades
- 10 of Diamonds
- Jack of Spades
- King of Hearts
- King of Spades
- Ace of Clubs
- 2 of Diamonds
- 7 of Hearts
- 2 of Clubs
- 6 of Clubs
- Jack of Diamonds
- Queen of Clubs
- 9 of Hearts
- 7 of Spades
- 6 of Hearts
- 7 of Hearts
- King of Clubs
- 2 of Spades
- 2 of Diamonds
- 4 of Hearts
- Queen of Diamonds
- 5 of Spades
- Ace of Hearts
- 6 of Spades
- 5 of Hearts
- 10 of Spades
- Jack of Hearts
- 8 of Hearts
- 2 of Hearts
- 5 of Clubs
- Jack of Clubs
- King of Hearts
- 7 of Clubs
- 6 of Diamonds
- 9 of Diamonds
- King of Diamonds
- 9 of Spades
- 3 of Clubs
- Ace of Spades
- 8 of Diamonds
- King of Spades
- 3 of Hearts
- Jack of Spades
- 7 of Diamonds
- 8 of Clubs
- 10 of Diamonds
- 9 of Clubs
- 10 of Clubs
- Ace of Diamonds
- Queen of Spades
- 3 of Diamonds
- Ace of Hearts
- 9 of Hearts
- 7 of Spades
- 6 of Diamonds
- Ace of Spades
- Queen of Clubs
- 3 of Hearts
- Queen of Spades
- 10 of Spades
- 7 of Diamonds
- 8 of Hearts
- 5 of Hearts
- 2 of Clubs
- 8 of Diamonds
- 8 of Spades
- King of Clubs
- Jack of Clubs
- 8 of Clubs
- 6 of Clubs
- 4 of Diamonds
- 6 of Hearts
- 10 of Clubs
- 4 of Clubs
- Ace of Clubs
- 9 of Clubs
- Ace of Diamonds
- 10 of Diamonds
- Jack of Spades
- King of Diamonds
- 6 of Spades
- 9 of Spades
- Jack of Diamonds
- 5 of Spades
- King of Hearts
- 2 of Diamonds
- Queen of Diamonds
- Queen of Hearts
- 3 of Clubs
- King of Spades
- 7 of Clubs
- 4 of Hearts
- 5 of Diamonds
- Jack of Hearts
- 3 of Spades
- 5 of Clubs
- 9 of Diamonds
- 7 of Hearts
- 2 of Hearts
- 4 of Spades
- 10 of Hearts
- 3 of Diamonds
- 2 of Spades
- 2 of Diamonds
- 9 of Hearts
- 8 of Spades
- 7 of Clubs
- 4 of Spades
- Ace of Hearts
- 5 of Diamonds
- 2 of Clubs
- Queen of Hearts
- 6 of Clubs
- Ace of Spades
- 10 of Hearts
- 5 of Spades
- Queen of Clubs
- 10 of Clubs
- 6 of Diamonds
- 7 of Hearts
- 8 of Clubs
- 3 of Diamonds
- 3 of Spades
- 2 of Spades
- 9 of Diamonds
- Jack of Clubs
- 10 of Spades
- 6 of Hearts
- King of Diamonds
- Jack of Spades
- Queen of Diamonds
- King of Spades
- Ace of Clubs
- 5 of Hearts
- 8 of Hearts
- 4 of Diamonds
- King of Hearts
- 7 of Diamonds
- 4 of Hearts
- Ace of Diamonds
- Jack of Hearts
- 9 of Clubs
- Jack of Diamonds
- 6 of Spades
- 10 of Diamonds
- 5 of Clubs
- 3 of Clubs
- 7 of Spades
- 9 of Spades
- King of Clubs
- 3 of Hearts
- 8 of Diamonds
- 4 of Clubs
- Queen of Spades
- 2 of Hearts
- King of Clubs
- 6 of Clubs
- Jack of Diamonds
- 7 of Spades
- 3 of Clubs
- 10 of Clubs
- 4 of Hearts
- 3 of Hearts
- Jack of Hearts
- 9 of Spades
- Queen of Clubs
- Queen of Hearts
- Ace of Hearts
- 5 of Hearts
- Ace of Spades
- 5 of Diamonds
- 5 of Clubs
- 4 of Diamonds
- 8 of Spades
- Jack of Clubs
- 3 of Diamonds
- 4 of Clubs
- 3 of Spades
- 7 of Clubs
- 10 of Spades
- 8 of Diamonds
- Queen of Diamonds
- 8 of Clubs
- 8 of Hearts
- 6 of Hearts
- Ace of Diamonds
- 6 of Diamonds
- 9 of Clubs
- Queen of Spades
- King of Diamonds
- 10 of Hearts
- 5 of Spades
- 2 of Hearts
- 2 of Clubs
- 7 of Diamonds
- 6 of Spades
- 4 of Spades
- 9 of Diamonds
- 9 of Hearts
- 2 of Spades
- 10 of Diamonds
- Jack of Spades
- King of Hearts
- King of Spades
- Ace of Clubs
- 2 of Diamonds
- 7 of Hearts
The first test run shows 104 cards (the equivalent of 2 decks of cards). The first 52 cards in that sequence is designated for the Blue Player and the latter 52 are for the Red Player.
The second test run shows 199 cards (beyond the maximum that should be used), and as a result it causes the code to go haywire and I get the wrong sub set off when I call a card higher than a 3, and although it is a 9, the HigherWrongCards sub is set off when it should be the HigherRightCards sub.
I can see why it is important for me to just do one test run, then close the project, then reopen it again, and do another test run. I will do a series of test runs over the coming days (opening the project once, test-running it, and closing the project afterwards) and see what results come out of it.
I apologize for the really long post, but I was just providing an example.
Please send me the app as it is now.
Actually, I just realized there are several things that have to be added/changed.
- The font used in the first question will involve a different font, and will allow for larger numeric answers (in this case, up to 4 digits). I will be adding the numeric answers for this question type to appear as if it was being typed on the podium. I will need some help for this.
- I will also be adding a new font resource to the code so that the exact font will be shown in that particular label.
- I will also be adding an animated banner that will drop towards the top of the contestant podium revealing the answer during this question type. It won't be exactly like it appears on the show (where on the show, the banner zooms inward), as it would take a lot more work. I don't have to make this game all exactly like the show, but to make it close enough.
- Also, I haven't gotten around to creating the Ace of Spades card that was miscreated (I unintentionally used a duplicate Ace of Clubs instead). I will work on that very soon.
- And the problem with regards to the "Invalid Picture" error message, when receiving the new files, have the red player guess the number "1" and the blue player guess lower. The red player will win control at the cards, and just as the card is expected to be revealed, the "Invalid Picture" error message pops up. This error message doesn't prevail when the blue player wins the question and wins first control of the cards.
The newly updated files will be sent by the weekend. :)
Well, there are a couple of things I mentioned in my previous post that I had to do before I send the updated copy that I had just completed:All the work I have to do this time around would be adding the font resource to the code as well as adding the appropriate font to the main folder (as mentioned in #2). The rest of what I mentioned (#1 and #5) I will need some help on.
- I got #3 completed just now - the animated banner is added to the form and its code for the educated guess questions just now. It was a new thing for me to learn, and I learned it myself! You'll be impressed by the animation I created when you receive the latest update.
- Also, #4 is scratched off the list, as I created the Ace of Spades (with the traditional "giant" Spade symbol in the center) card that is needed.
It looks like this folder will be sent to you much sooner. Possibly by tomorrow, most likely.
I just added the font resource and the new font is now in the folder. Look for an updated folder by PM tomorrow morning!
Sent the updated form to you, Marty. :)
Also, there are significant enhancements to the game that you might want to check out!
Invalid picture solved!
Code:Public Sub RevealFirstRedCard()
'Marty
LoadCards "Cards"
'rest of the code
Lets now talk about the subsequent test runs going beyond 104 cards problem.
The first thing I need to know is what exactly is a "second test run"? That may sound like a silly question but I don't know for sure what you mean by a "test run". What I assume you mean is that a test run starts with you starting the program answering some questions, etc and then closing the program. So a "second test run" would be doing that again. Is that what you mean? Because if it is I'm confused because there is absolutely no way that your app could deal too many decks or cards the second time if it doesn't do it the first time.
Thanks!
Now the only problem that remains is the card sequence issue. For that, I will compile the updated code into an EXE, and do some test runs with that EXE file. If no problems prevail, then the problem was already solved.
As of the most recent testing, the red player had a 3 to start. Called it lower, and (surprisingly) got a 2. Called it lower than a 2 (intentionally), and got a king.
When that same red player won the next question, he had to start from the 3. He called it higher. The last card recorded was a King, and although the result was a Queen, the right sub was activated (the HigherRightRedCards sub).
As of right now, it looks promising. It's possible that with more than one test run in the Project file while that project file is still open, the number of cards that are displayed in the display window does happen to exceed the maximum 104 that should prevail.
A couple of more test runs, and if they pass, I will safely declare the biggest problem with the game solved. Then it is smooth sailing from there on in.
Could you please explain what you mean when you say "It's possible that with more than one test run in the Project file while that project file is still open, the number of cards that are displayed in the display window does happen to exceed the maximum 104 that should prevail". Because again I'm not sure what "more than one test run in the Project file" means.
A "test run" is opening the project file, and clicking the "start" button to test the game. The "start" button is the one with the triangle near the top of the screen (it should be near the Pause and the Stop buttons).
You can also do a test run by going to the "Run" menu, and selecting "Start" or "Start with full compile."
You can "start" the run by clicking the "start" button, and you can stop it at any time by clicking the button with the square on it, as well you can pause the run. After you click "stop", you can "start" the run again by clicking "Start."Quote:
Originally Posted by MartinLiss
So I guess what I meant by "test run" was probably confusing, and I am sorry for not being clear enough.
Okay so when you talk about a test run you mean starting the app and in that case as I said previously there is absolutely no way that your app could deal too many decks or cards the second time if it doesn't do it the first time. I believe what you are seeing in the Immediate window is just some values left over from the previous test and they have no effect whatsoever on the current test. To avoid confusion you could (between test runs) set focus to that window, click ctrl-A and then click Delete.
Some things I've noticed.
1)
In your DealBlueCard and DealRedCard subs you don't use i, X or OldSlot you also have code that checks to see if BlueCards(currentCard) > 51 and I don't think that that's ever possible. Also you have code in two places that checks to see if the deck needs to be shuffled so I think DealBlueCard could (and probably should) be changed to
and similar for DealRedCard. You'll also of course have change how those subs are called because there is now just one parameter.Code:Private Function DealBlueCard(Ctrl As Control) As Integer
Ctrl.Picture = cards(BlueCards(currentCard))
Picture1.AutoRedraw = True
Picture1.PaintPicture Ctrl.Picture, Ctrl.Left, Ctrl.Top
Picture1.AutoRedraw = False
Ctrl.Tag = BlueCards(currentCard)
currentCard = currentCard + 1
If currentCard > 52 Then ShuffleBlueCards 'Note I changed this to 52 (that's correct right?)
Me.Refresh
DealBlueCard = Ctrl.Tag Mod 13
End Function
2) In Form_Load I found
which should be changed toCode:Picture1 = LoadPicture(App.Path & "\cards\bkgd-bothdim.bmp")
3) In your BlueHigherRight and similar subs you have the following code repeated 13 times.Code:Set Picture1.Picture = LoadPicture(App.Path & "\cards\bkgd-bothdim.bmp")
and you could just have a Dim lngIndex As Long and then replace those 13 occurrences with this one loopCode:BlueHigher.Visible = True
Set Picture1.Picture = BLBkgdFlash
Wait 200
BlueHigher.Visible = False
Set Picture1.Picture = BkgdBothDim
Wait 200
4) I have a piece of software that let's me analyze the code in a project and when I ran it against yours it told me that you have four command buttons that don't have code in their Click events and they are:Code:For lngIndex = 1 to 13
Set Picture1.Picture = BLBkgdFlash
Wait 200
BlueHigher.Visible = False
Set Picture1.Picture = BkgdBothDim
Wait 200
Next
btnBPlayCds
cmdBPassCds
cmdRPassCds
cmdRPlayCds
It also pointed out that you have several "dead" procedures (in other words not used) and they are:
cmdRChangeCd_Click
cmdBChangeCd_Click
btnPlayBCds_Click
btnPlayRCds_Click
LastCardRedWin
LastCardBlueWin
SetRDEGNumber
SetBLEGNumber
RedFreezeBar
BlueFreezBar
Comparing those two lists points out that in the case of btnBPlayCds in the first list and btnPlayBCds_Click in the second that you have forgotton to complete a name change.
If the rest of the procudures in the 2nd list aren't needed any longer then you should delete them.
Another thing. If I answer the first question with a number > 9999 it tells me that the "Answer must be between 0 and 9999" however it lets the game proceed. To prevent that you should add an Exit Sub as shown below.
You also don't use "i" in that sub so you should delete the Dim for it. You should look at your other similar subs and add Exit Sub statements if needed.Code:Private Sub cmdEnterEGR_Click()
Dim i As Integer
If Val(txtGuess.Text) < 0 Then
MsgBox "Answer must be between 0 and 9999."
cmdEnterRegR.Enabled = True
ElseIf Val(txtGuess.Text) > 9999 Then
MsgBox "Answer must be between 0 and 9999."
cmdEnterRegR.Enabled = True
Exit Sub
Else
'~~~> Your text or question
strTemp = txtGuess.Text '-- If you don't set it no text can be animated!
n = 1
Timer7.Enabled = True
Timer7.Interval = 200
cmdEnterRegR.Enabled = False
cmdEnterRegR.Visible = False
End If
Me.Refresh
WhosTurn = BluePlayer
AskHigherLowerEGBlue
End Sub
Another problem with that sub is that a player can answer with, say, "four" instead of "4". When that happens Val(txtGuess.Text) is zero so the guess is treated as if the user entered zero. If you'd like to be able to prevent that (and also prevent a minus sign from being entered) then add this sub
The user could still paste an invalid value into txtGuess and if you want to prevent that then let me know.Code:Private Sub txtGuess_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Actually, 3 of the "dead" procedures (cmdBPassCds, cmdRPassCds, and cmdRPlayCds) are only there because they will be used eventually in other questions.
Also, a brief explanation on some of the following "dead" code as displayed in green text:
Other than that, thanks for the most recent tips!Quote:
Originally Posted by MartinLiss
Actually cmdRChangeCd_Click and cmdBChangeCd_Click aren't used because you don't have controls with those names. You have instead cmdChangeRCd and cmdChangeBCd.
Here's a picture of what my software pointed out as dead constants and declarations. They can be deleted.
Attachment 75855
and these are dead variables.
Attachment 75856
Finally, (for today at least:) ) here are some more things to ponder.
- The form's caption still says "Form1"
- Would you like to always have the form open in the middle of the screen? Or would you like to remember where it was the last time you played?
- You have Wait 3000 at the end of StartR1 and also in ShowEGQuestion. You don't need both and I think it runs smoother if you remove the one in StartR1 and change the other to 500.
- The numbers that appear in RDNumber have an underscore and a line through them as in this picture
Fixed.Quote:
Originally Posted by MartinLiss
It would be nice to have the form open mid-screen. How do I do this?Quote:
Originally Posted by MartinLiss
The Wait 3000 is at the end of StartR1 because there is a final caption in StartR1 that needs to be shown before the next sub is set off. Doing Wait 3000 will allow for that, and eliminating it means the caption will disappear. However, I did change the Wait 3000 in the ShowEGQuestion to Wait 500.Quote:
Originally Posted by MartinLiss
Funny, because I never had that underscore and strikethrough problem on my side. Do you have the right font? The font is called "Clarendon" and it should be in the last folder I sent you.Quote:
Originally Posted by MartinLiss
BTW, either way, it seems as if I am very close to completing Round One of the game in terms of coding, and pretty soon it will be on to Round Two.
To have the form always open mid-screen change it's StartUpPosition property in the IDE to "2 CenterScreen".
Yes I have clarendo.ttf in the same folder with sportstype.ttf
I found the problem with the font. Somehow (in my copy at least), both the Strikeout and Underline options in the Effects frame of the Font dialog for RDNumberEG(0) and RDNumberEG(1) were selected and the Strikeout option was selected for BLNumberEG(0) and BLNumberEG(1). I unselected them and now I'm fine.
Another small problem that I've had from the beginning of working on your project is that after starting the program the form would disappear soon after "come in gang" and I'd have to manually click it once or twice in the bottom bar (the name of which I always forget) to get it to appear again. Does that happen to you as well? I just found out that for some reason it was the calling of Sleep in the Wait routine that was causing the problem. If you change the sub to look like this then the problem goes away.
There is now no longer any call to Sleep in that sub. I'd say that you could delete the declaration for the Sleep function but in four places you call Sleep directly instead of calling Wait. You should change that so that you are consistent.Code:Public Sub Wait(intHowLong As Integer)
Dim sngClock As Single
sngClock = Timer
While Timer < sngClock + (intHowLong / 1000)
DoEvents
Wend
End Sub
In the Wait sub above you'll notice that intHowlong is divided by 1000. That's because the Timer function that it calls returns a value representing the number of seconds elapsed since midnight rather than the milliseconds that Sleep deals with. If you decide to change the Wait sub you could keep it like it is above or you could do this
but if you did that you would need to change all your calls to Wait from things like Wait 500 to Wait .5Code:Public Sub Wait(sngHowLong As Single)
Dim sngClock As Single
sngClock = Timer
While Timer < sngClock + sngHowLong
DoEvents
Wend
End Sub
I did a few tests on the entire Round One throughout today, and I discovered that there are still problems with the card turning vs. setting off the right or wrong subs, but only prevalent after Question #2 and Question #3. Question #4 seems to work without any problems, strangely enough.
I am just wondering something here...
I wonder if it's possible that, because I use the same buttons for more than one sub, that it may throw off my code and that may be the reason why the cards seem to flaw in Question #2 and #3, but not Question #1 and #4?
I revamped the code (saving the original backup first, of course) and used the following buttons in the following subs:
By giving each sub a numeric label (2, 3, 4, etc.) and separate command buttons inside each sub, maybe that might solve the problems with the card turning and setting off the right subs.Code:Private Sub RevealFirstRedCard() ' Or RestartRedCards
' buttons only
cmdChangeRCd.Visible = True
cmdChangeRCd.Enabled = True
cmdHigherRCds.Visible = True
cmdHigherRCds.Enabled = True
cmdLowerRCds.Visible = True
End Sub
Private Sub RevealFirstBlueCard () ' Or RestartBlueCards
' buttons only
cmdChangeBCd.Visible = True
cmdChangeBCd.Enabled = True
cmdHigherBCds.Visible = True
cmdHigherBCds.Enabled = True
cmdLowerBCds.Visible = True
cmdLowerBCds.Enabled = True
End Sub
Private Sub RevealFirstRedCard2 () ' Or RestartRedCards2
cmdChangeRCd2.Visible = True
cmdChangeRCd2.Enabled = True
cmdLowerRCds2.Visible = True
cmdLowerRCds2.Enabled = True
cmdHigherRCds2.Enabled = True
cmdHigherRCds2.Visible = True
End Sub
Private Sub RevealFirstRedCard3 () ' Or RestartRedCards3
cmdChangeRCd3.Visible = True
cmdChangeRCd3.Enabled = True
cmdLowerRCds3.Visible = True
cmdLowerRCds3.Enabled = True
cmdHigherRCds3.Enabled = True
cmdHigherRCds3.Visible = True
End Sub
Private Sub RevealFirstBlueCard3 () ' Or RestartBlueCards3
cmdChangeBCd3.Visible = True
cmdChangeBCd3.Enabled = True
cmdLowerBCds3.Visible = True
cmdLowerBCds3.Enabled = True
cmdHigherBCds3.Enabled = True
cmdHigherBCds3.Visible = True
End Sub
Private Sub cmdHigherBCds_Click () ' Or Lower
AnswerHigherRedCards ' Or Lower
End Sub
Private Sub cmdHigherBCds2_Click () ' Or Lower
AnswerHigherRedCards2 ' Or Lower
End Sub
Private Sub cmdHigherBCds3_Click () ' Or Lower
AnswerHigherRedCards3 ' Or Lower
End Sub
I will compile the new code first in the morning, and do some testing with it, and I'll be providing a feedback report about it at some point tomorrow or Friday.
IMO it's a very bad idea to add more command buttons when you could I'm sure reuse the ones you have with very little effort. Otherwise you create a maintenance nightmare. It also wouldn't hurt to mention that there's a limit of 255 controls on a form and while you now have only 84, it's something to be aware of.
In any case before you ship me a new set of code I'd appreciate it if you would look at the Font settings on your side so that I don't have underlines and strikeouts and also I'd like you to consider changing the Wait sub.
BTW, how do I do a count to see how many controls I have on my form?
At any place in the execution of the program, place it in break mode and in the Immediate window type ?controls.count and press return. "Controls" is the name of a collection that contains information about all the controls on a form and Count is a property of all collections.
If you don't think that reusing buttons is workable then you should at least consider control arrays. If you haven't used them here's a trivial example.
Here.
^ Thanks!
Oh, and I do have some news to share (some good news, and some sort of bad news)...
First the bad news...
Earlier this afternoon, on my way home from getting groceries, I tweaked my right knee as I was carrying groceries. I believe the heavy cans in the bag hit my knee as if it almost dislocated, but thankfully didn't. I was uncertain if I injured it even just slightly. But thankfully, I went to the emergency room and the doctor told me I might have given a certain muscle a bit of a blow and it is a bit tender. I will still be on the computer, but until the worst of my tenderness is over (which might be by Sunday or sometime during the first week of February), my project will be on hold.
Now for the good news...
I was doing a major revamp of the code in recent days, and I am adding control arrays in almost every sub! That will take a significant cut on all the controls, as using a sub and having a "Select Case Index" in those subs will probably make the code more efficient and use less control subs in a single form.
When my knee is much better, I will resume the coding already in progress. :)
In the meantime, regardless of my problems today, I did just do a compile, and I tried doing this so that I can allow subdivisions within the same sub.
Here is an example:
Code:Private Sub cmdRFreeze_Click(Index As Integer)
Select Case Index
Case 0
If CurrentRedSlot = 1 Then
FreezeRedPlay(1, 1) = 0 <== Expected Function or Variable Error prevails.
ElseIf CurrentRedSlot = 2 Then
FreezeRedPlay(2, 1) = 0
ElseIf CurrentRedSlot = 3 Then
FreezeRedPlay(3, 1) = 0
End If
...
End Select
End Sub
After doing a compile, I got an error message with regards to a line and possibly a series of lines as noted in red text. What would I have to do to fix this problem?Code:Public Sub FreezeRedPlay(Index As Integer, Ques As Integer)
Dim sfile As String
Select Case Index
Case 1
sfile = App.Path & "\sounds\freeze.wav"
sndPlaySound sfile, SND_ASYNC
FreezeCard(WhosTurn) = 1
RFreeze.Caption = "1"
cmdChangeRCd.Visible = False
cmdChangeBCd.Visible = False
cmdChangeRCd.Enabled = False
cmdChangeBCd.Enabled = False
cmdHigherRCds.Visible = False
cmdHigherRCds.Enabled = False
cmdLowerRCds(0).Visible = False
cmdLowerRCds(0).Enabled = False
cmdRFreeze.Visible = False
If RFreezeBar.Left = "3720" Then
RFreezeBar.Left = "3840"
lblRNameBar.Left = "3960"
For i = 0 To 1
SetDialog CurName & "Player Freezes"
Next
Wait 30
RFreezeBar.Left = "3960"
lblRNameBar.Left = "4080"
Wait 30
RFreezeBar.Left = "4080"
lblRNameBar.Left = "4200"
Wait 30
RFreezeBar.Left = "4200"
lblRNameBar.Left = "4320"
Wait 30
RFreezeBar.Left = "4320"
lblRNameBar.Left = "4440"
Wait 30
RFreezeBar.Left = "4440"
lblRNameBar.Left = "4560"
Wait 30
RFreezeBar.Left = "4560"
lblRNameBar.Left = "4680"
Wait 30
RFreezeBar.Left = "4680"
lblRNameBar.Left = "4800"
Wait 30
RFreezeBar.Left = "4800"
lblRNameBar.Left = "4920"
Wait 30
RFreezeBar.Left = "4920"
lblRNameBar.Left = "5040"
Wait 30
RFreezeBar.Left = "5040"
lblRNameBar.Left = "5160"
Wait 30
RFreezeBar.Left = "5160" 'CurrentSlot1
lblRNameBar.Left = "5280"
RFreeze.Caption = "1"
Wait 3000
Select Case Ques
Case 1
StartQuestion (2)
Case 2
StartQuestion (3)
Case 3
StartQuestion (4)
Case 4
If CurQues.Caption = "R" Then
StartQuestion (8)
ElseIf CurQues.Caption = "B" Then
StartQuestion (7)
End If
Case 5
If CurQues.Caption = "R" Then
StartQuestion (10)
ElseIf CurQues.Caption = "B" Then
StartQuestion (9)
End If
Case 6
If CurQues.Caption = "R" Then
StartQuestion (12)
ElseIf CurQues.Caption = "B" Then
StartQuestion (11)
End If
End Select
End If
...
End Select
End Sub
It thinks you're trying to set FreezeRedPlay to zero. You can't set subs to anything.
But when I use just simply:
It does nothing. I press enter after that line of code, and I get a pop-up dialog box and it requires an equal sign at the end of that line (I think the error message said "Expected End of Statement"?). That particular line and the like turns into red text as a result.Code:FreezeRedPlay(1, 1)
EDIT: The error message said "Expected function or variable." What are some recommendations?
I tried removing the "= 0", "= 1", etc., and I put Call before the FreezeRedPlay(#, #), and I compiled it, and there may be no problems. Is that a good idea?
Also, might I suggest this thread's topic be changed to "Card Sharks Project"?
Do either of the following.
Call FreezeRedPlay(1, 1)
FreezeRedPlay 1, 1
I was already ahead of the game with Call FreezeRedPlay(1, 1). Thanks for the help!
I got to go to bed now as I post this, and I have to give my knee a rest. Hopefully I will be better soon so I can resume this project. The revamp is going really well, I think!
I realized that I have too many controls in the game (last I checked I had almost 175 out of the maximum 255 used on a form). Also, to allow for easier maintenance, I put each of the 3 rounds on separate forms. Doing this will allow for ample free space and I realize that some games require more than one form, but at least there won't be too many.
At least I am consolidating the questions and the card playing onto one form, but it turns out that putting the gameplay elements on 3 separate forms is the only way I can avoid getting very close to capacity for a form.
I should have mentioned that for the purposes of the 255 limit, all the members of a control array count as a total of only one control.
Thanks for the reminder, but I did do a control array count and it did come up 174 or around there. Just to be safe, I decided to do individual forms for each of the 3 rounds of game play. And besides, it's easier for me to maintain than having to go through all that consolidated code.
I know you've made up your mind to create three forms so I won't try to get you to change your mind but help me understand something. The last update you sent me contained almost complete code for the first round and you had 84 controls. I know you started to use control arrays after that so how is it that you needed to increase to 174? Aren't the rest of the rounds basically the same as the first round?
There were add-ons in terms of labels, images, subs, and other stuff. I don't remember when I sent you the recent update, but I was kind of surprised to notice that there were more than double the controls on my side as opposed to your most recent delivery.
Even labels (that I assume you are using in large part to keep track of totals) can be control arrays, and so can images and each can have it's own picture.
Anything that can exist on the top of the form that can be accessed from a drop-down menu, I believe, are controls/control arrays, in other words. I figured out why there were more than double on my update than the 84 on your last delivery. I see the picture. :)
A menu item fits that description but menu items aren't controls and they can't be arrays. A control is one of the objects that are shown in the Toolbox or listed after you select Project|Components. A control array is a group of controls that share the same name and type. Members of a control array are referenced via their index; eg MyLable(4) which would refer to the 5th member of the control array.
I am still trying to figure out the problem with the cards, and I am still having problems with setting off the right sub, but the problem only prevails when the red player wins the first question and that same red player wins the second and third questions in a row. Same theory for when the blue player wins the first question and the second/second and third questions as well. The first two questions the red player wins is not a problem at all.
BTW, I uploaded a video to show where the problem lies. View this clip in its entirety and you'll see what I am talking about and where the problem lies:
http://www.youtube.com/watch?v=fiU9zWHXlok
An updated folder will be sent to you later today.
To be honest with you Jon I couldn't follow the video well enough to understand (or see) the problem. BTW it looked to me as if you were stopping and starting the video because the guesses you made were wrong and so you had to back up and try again and so it was confusing to watch. I'm not asking you to redo it but maybe a documant that explains step by step what is happening in the video and what should happen would help.
To help with your next video (if there is one) do you realize that unless you've removed the Debug.Print statements in the shuffle routines that the "deck" is displayed in the Immediate window so you can see what card will be next. To have the list of cards handy you could break the program just after it starts, do a Ctrl-A in the Immediate Window, copy it and paste it into NotePad and then print it.
Also about the video, I have no problem with it being on YouTube, but you could just upload the avi file or whatever it is to SendUIt and I could download and run it on my PC.
The guesses I made were wrong because sometimes the player may call the card higher, and while it may be higher, the HigherWrongCards sub is set off instead.
I am attaching a Word document to explain in detail where the problem lies, and where the problem is very vulnerable to occur.
In looking at the code that I have I noticed two things, 1 minor and 1 perhaps major.
The minor thing is that in AnswerLowerBlueCards, AnswerHigherBlueCards, AnswerHigherRedCards, and AnswerLowerRedCards you define j and you set it to oldCardValue but you never use j after that so for clarity sake you should get rid of it.
The major thing is that you have just one oldCardValue for both the red and blue player. Don't you need two different variables that could be called perhaps oldRedCardValue and oldBlueCardValue?
Here's a trick that might help your testing. The highlighted lines will set up the blue deck so that the first 11 cards are the 2 to queen of spades.
Instead of those lines you could set up any values you want by doing something like the following which would result in the first 4 cards being the 2 of Clubs, 10 of Clubs, 3 of Clubs and Jack of Diamonds.Code:Private Sub ShuffleBlueCards()
Dim X As Integer, i As Integer, j As Integer
'load the deck
For i = 0 To 51
BlueCards(i) = i
Next
Randomize
'shuffle
For i = 0 To 51
X = Int(Rnd() * 51) + 1
j = BlueCards(i)
BlueCards(i) = BlueCards(X)
BlueCards(X) = j
' Debug.Print BlueCards(i) & " ";
Next
Debug.Print "------- Shuffle Blue Cards -------"
For i = 0 To 10
BlueCards(i) = i
Next
For i = 0 To 51
Debug.Print NameCard(BlueCards(i))
Next
End Sub
Code:BlueCards(0) = 13
BlueCards(1) = 21
BlueCards(2) = 14
BlueCards(3) = 48
I did a test using the oldRedCardValue and the oldBlueCardValue variables, and with the "test" cards each player started with the 2, then called it lower than 2 (intentionally), and it was a 10. When the red player won the second question, he started from the 2, and guessed higher than the 2. Since the last card for the red player was a 10, guess what? While it was higher than the 2 (it was a 3), the right sub (HigherRightCards) was set off!
I guess it may be proven that using oldCardValue is just consolidating both decks of the cards and that may be why the code was screwed up a bit - why I was getting the wrong sub set off when I was getting a card higher and the HigherWrongCards sub is wrongfully set off.
I will do a series of tests over the course of the day and maybe into Saturday, and if there's positive results, it looks like it will be on to the second round (which will only be a simple copy/paste job and maybe some slight editing).
Marty, do you happen to have the most recent file folder I sent you? I may have edited the code and saved it as the same file by mistake. If you do, can you please send it back to me?
Apparently, I still have the problem with regards to the flipping of the cards and the wrong sub being activated. But I do have some positive news that the playing of the cards is based on consecutive plays of the cards.
Here is what I have recorded thus far:
Blue Player wins first question - No problems.
Red Player wins second question.
Blue Player wins third question - No problems.
Blue Player wins fourth question - but this is where the problem lies, as he calls the card higher than the 4 and while it is a 7, the wrong sub is set off.
It seems as if the game may follow a pattern that the cards will run smoothly if it's 3 consecutive plays of the cards and maybe not more, and definitely if it's 3 non-consecutive plays of the cards. Originally, the problem was with 2 consecutive plays vs. 2 non-consecutive plays, and now it seems to be with 3 consecutive vs. 3 non-consecutive, maybe 4.
I think the game should run more smoothly and the same blue (or red) player should get the right cards with the right sub set off if he/she wins four consecutive questions.
Is it possible I may have to add the following lines of code:
For the RevealFirstCard and the RestartTurnCards:
RedFirstPlay = 0
RedFirstPlay = RedFirstPlay + 1
BlueFirstPlay = 0
BlueFirstPlay = BlueFirstPlay + 1
And for use in the RestartFreeShot and RevealFreeShot subs:
RedSecondPlay = 0
RedSecondPlay = RedSecondPlay + 1
BlueSecondPlay = 0
BlueSecondPlay = BlueSecondPlay + 1
Would you recommend this idea? And how do I go about coding the card playing so that I can have the game run more smoothly with the blue (or red) player winning the first question for 3 non-consecutive times?
Create a new zip for me and I'll take a look at it.
Before I do send you the zip folder, I will let you know that I experimented with additional subs for the card playing (with the taglines "Two", "Three" and "Four" on them). The first three card playings seem to work when that same blue (or red) player wins the first three questions all in a row. But when the blue (or red) player wins the first question, and not the second, but wins the third and fourth question, there's a skipping involved and that results in the player's non-consecutive third play of the cards (usually after the fourth question) not setting off the right sub.
I just did a test run, and now the problem prevails when the same blue (or red) player wins his/her fourth question in a row and chooses to play the cards instead of passing.
When the blue player chooses to play the cards after the fourth question (sudden death), that blue player had a 3 as his/her base card, and he/she called it higher than the 3, and while it is an 8 (the previous blue card revealed in the blue player's last playing was a 10), it activated the opposite sub (RedGameWinBLoss) instead of setting off the HigherRightCardsFour sub.
At least we seem to be on the right track and we can get through the first three questions no problem. But the fourth playing of the cards is a big problem, if the blue player (or red player) wins that question and elects to play the cards instead of passing.
I've found some problems, maybe not the problem, but problems nonetheless.
You should never have a form-level variable with the same name as a code module variable but you do.
1) You have "playing" defined in the form and also in GameEssentials. You set the value of playing but you never actually inquire as to its value so you don't need either one at all but for now you should just delete the one in the form.
2) You have cards() defined in both places. In the form you have it defined cards(0 to 51) which is 52 cards, but in GameEssentials you have it defined cards(0 to 53) which is 54 cards. You should get rid of one of them and decide if your deck will have 52 or 54 cards (2 jokers?).
I don't know if 2) is causing your problem but let me know.
#2 is probably because the form may work properly without the module. The cards() in the GameEssentials6 module is for use in the Money Cards, which was already worked on last spring (yes, there are some parts of the game that are completed already).
As for #1, I saved the module and deleted the "playing" from the newly saved module.
What do you mean by that?Quote:
Originally Posted by MartinLiss
Guess what?
The blue player won four questions in a row, and he/she played the cards every time without any problems! This means the wrong sub didn't get set off all four times!
Tomorrow morning, I will do a test run with the blue player winning the first question, and the red player winning the second question, and the blue player winning the remaining two questions, etc., and see what results I get. It looks promising that there is significant progress now!
In GameEsentials you have the code module variable
while in Round1f you have the form-level variableCode:Public playing As Boolean, cards(0 To 53) As StdPicture, rand(0 To 53) As Integer
If you refer to cards in the form, do you know which cards definition you are referring to? Even if you do it's confusing and you don't need both. If you think you will at some time need two of them then rename one of them now.Code:Dim cards(0 To 51) As StdPicture, BlueCards(0 To 51) As Integer, RedCards(0 To 51) As Integer