Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-04-2005, 03:36 PM   #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.
Attached Files
File Type: zip Hangman.zip (2.1 KB, 106 views)
ecchikinetic is offline   Reply With Quote
Old 04-05-2005, 08:20 AM   #2
Come in Ray...
 
faulkner132's Avatar
 
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.
faulkner132 is offline   Reply With Quote
Old 04-05-2005, 02:15 PM   #3
Member (5 bit)
 
Join Date: Feb 2005
Posts: 18
Quote:
Originally Posted by faulkner132
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
So where should I place that line?
ecchikinetic is offline   Reply With Quote
Old 04-05-2005, 02:24 PM   #4
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
On the line which says "Call checkLetter(x)", replace x with the code above.
faulkner132 is offline   Reply With Quote
Old 04-05-2005, 03:14 PM   #5
Member (5 bit)
 
Join Date: Feb 2005
Posts: 18
Quote:
Originally Posted by faulkner132
On the line which says "Call checkLetter(x)", replace x with the code above.
Ok I got it to work now thanks. Anyways I have another issue about shell game. This time the user gets a second guess to where the pearl is and also everytime I click to guess the pearl keeps getting randomize. Anyway heres the file.
Attached Files
File Type: zip Shell Game.zip (662 Bytes, 92 views)
ecchikinetic is offline   Reply With Quote
Old 04-05-2005, 07:44 PM   #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?
foolishone is offline   Reply With Quote
Old 04-06-2005, 07:32 AM   #7
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
It's not corrupt, only the project file is in it.
ecchikinetic, there is no code included.
faulkner132 is offline   Reply With Quote
Old 04-06-2005, 01:56 PM   #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.
Attached Files
File Type: zip Shell Game.zip (1.6 KB, 68 views)
ecchikinetic is offline   Reply With Quote
Old 04-06-2005, 05:17 PM   #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
foolishone is offline   Reply With Quote
Old 04-07-2005, 11:54 AM   #10
Member (5 bit)
 
Join Date: Feb 2005
Posts: 18
Heres the image file.
Attached Images
File Type: jpg codess.JPG (82.2 KB, 54 views)

Last edited by ecchikinetic; 04-07-2005 at 12:08 PM.
ecchikinetic is offline   Reply With Quote
Old 04-07-2005, 12:33 PM   #11
Come in Ray...
 
faulkner132's Avatar
 
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.
faulkner132 is offline   Reply With Quote
Old 04-07-2005, 04:25 PM   #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
ecchikinetic is offline   Reply With Quote
Old 04-08-2005, 07:35 AM   #13
Come in Ray...
 
faulkner132's Avatar
 
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.
faulkner132 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:20 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2