|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (5 bit)
Join Date: Feb 2005
Posts: 18
|
Hangman Problem 'Subscript out of range'
Heres the attachment, I can't seem to figure what the problem is.
|
|
|
|
|
|
#2 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
You do not set a value for x in your call after you get the letter. You should pass in the adjusted value of the ascii char... something like:
Code:
26 - (Asc("Z") - Asc(Ucase(strGuess))) 'character value between 1 and 26
Last edited by faulkner132; 04-05-2005 at 08:23 AM. |
|
|
|
|
|
#3 | |
|
Member (5 bit)
Join Date: Feb 2005
Posts: 18
|
Quote:
|
|
|
|
|
|
|
#4 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
On the line which says "Call checkLetter(x)", replace x with the code above.
|
|
|
|
|
|
#5 | |
|
Member (5 bit)
Join Date: Feb 2005
Posts: 18
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Member (9 bit)
Join Date: Nov 2004
Location: Flint, MI
Posts: 256
|
Haven't looked at the code yet but what is the problem exactly? Counting the clicks? Deteremining where they clicked?
^fo EDIT: Is that file corrupt or is it me? |
|
|
|
|
|
#7 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
It's not corrupt, only the project file is in it.
ecchikinetic, there is no code included. |
|
|
|
|
|
#8 |
|
Member (5 bit)
Join Date: Feb 2005
Posts: 18
|
Sorry bout that, here you go. As for my problem I want the user to get 2 guesses to know where the pearl is but the problem is that everytime I click the shell it randomizes the pearl to switch even if you clicked all 3 shells. As well as for the 2nd user to either take his guess or pick another one.
|
|
|
|
|
|
#9 |
|
Member (9 bit)
Join Date: Nov 2004
Location: Flint, MI
Posts: 256
|
(I still can't download the thing...stupid file)
Couldn't you just put a variable in a form or image click event that just adds one to itself when the form/image was clicked on, and somewhere else get the value and if it is two (ie. the form/image was clicked twice), randomize and reset the variable to 0...if I understood you correctly. The even if you clicked all 3 shells loses me. ^fo |
|
|
|
|
|
#10 |
|
Member (5 bit)
Join Date: Feb 2005
Posts: 18
|
Heres the image file.
Last edited by ecchikinetic; 04-07-2005 at 12:08 PM. |
|
|
|
|
|
#11 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Everytime the user clicks a pearl, you are resetting the intShellWithPearl variable. Move this line to a different function.
|
|
|
|
|
|
#12 |
|
Member (5 bit)
Join Date: Feb 2005
Posts: 18
|
Ok I seem to be getting somewhere now but I still don't know what's the command for limiting the number of clicks in the pearl before the inputbox pops up?
Code:
Option Explicit
Const strYes As String = "y"
Const strNo As String = "n"
Private Sub cmdDone_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim intIndex As Integer
Randomize
'Hide pearls at start of program
For intIndex = imgPearls.LBound To imgPearls.UBound
imgPearls(intIndex).Visible = False
Next intIndex
End Sub
Private Sub imgShells_Click(index As Integer)
Dim intShellWithPearl As Integer
Dim intNumberGuess As Integer
'Pick the shell that hides the pearl
If intShellWithPearl = index And intShellWithPearl = Int((imgPearls.UBound - imgPearls.LBound + 1) * Rnd + imgPearls.LBound) Then
MsgBox "You Win!"
imgPearls(intShellWithPearl).Visible = True 'Show the pearl
Else
MsgBox "Try again!"
imgPearls(intShellWithPearl).Visible = False
End If
Call SecondChance(index)
End Sub
Sub SecondChance(index As Integer)
Dim intShellWithPearl As Integer
Dim strConfirmation As String
intShellWithPearl = Int((imgPearls.UBound - imgPearls.LBound + 1) * Rnd + imgPearls.LBound)
If intShellWithPearl = index Then
imgPearls(intShellWithPearl).Visible = False
strConfirmation = InputBox("Are you sure? ('y' to choose the shell and 'n' to select diffrent shell)", "Shell Game")
Else
imgPearls(intShellWithPearl).Visible = False
strConfirmation = InputBox("Are you sure? ('y' to choose the shell and 'n' to select diffrent shell)", "Shell Game")
End If
If strConfirmation = strYes And intShellWithPearl = index Then
MsgBox "You Win!"
imgPearls(intShellWithPearl).Visible = True 'Show the pearl
ElseIf strConfirmation = strNo Then
Call Temp(index)
End If
End Sub
Sub Temp(index As Integer)
Dim intShellWithPearl As Integer
If intShellWithPearl = index And intShellWithPearl = Int((imgPearls.UBound - imgPearls.LBound + 1) * Rnd + imgPearls.LBound) Then
MsgBox "You Win!"
imgPearls(intShellWithPearl).Visible = True 'Show the pearl
Else
imgPearls(intShellWithPearl).Visible = False
End If
End Sub
|
|
|
|
|
|
#13 |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Just have a counter variable and increment it everytime the user clicks. Once the counter is equal to 2, fire your events.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|