Announcement

Collapse
No announcement yet.

Visual Basic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Visual Basic

    I ran into a couple issues with my hangman program I'm working on for class,
    If anyone wouldn't mind helping me post here...

    http://rafb.net/p/s7R8bI96.html
    is the code for that whole class



    Problem #1
    Code:
        Public Enum HANGMAN_STATUS As Short
    
            HEAD = 1
           picHangman = Image.FromFile(strFileName & ".jpg")
            NECK = 2
            BODY = 3
            LEFT_ARM = 4
            RIGHT_ARM = 5
            LEFT_LEG = 6
            RIGHT_LEG = 7
            LEFT_FOOT = 8
            HUNG = 9
        End Enum
    ^ picHangman = Image.FromFile(strFileName & ".jpg")
    I want to call for each enum, 1-9 jpg are the images of the hangman body
    HEAD, HEAD+NECK, etc.
    It says strFileName, isn't declared. Yea I know declare it but how do I get it do go through 9


    Problem #2
    Code:
        Public Sub TryALetter(ByVal chrGuessLetter As Char)
            Dim mWordChar 'character of the word to check
    
            Dim i As Short
            Dim ModifiedWordArray As Char() = New Char(26) {}
    
            ' If mOriginalWord.IndexOf("Q") >= 0 Then
            'If mWord.IndexOf(chrGuessLetter) >= 0 Then
            '    mUncoveredLetters = mWord.IndexOf(chrGuessLetter)
    
            '    ModifiedWordArray = mWord
    
            '    For i = 0 To (mWord.Length - 1)
    
            '    If mWord(AscW(mWord.Chars(i))) = mWord.IndexOf(chrGuessLetter) Then
    
            '        ' mUncoveredLetters =
            '    Else
            '        'where to hang them
            '    End If
    
            'Next
            '   mModifiedWord = ModifiedWordArray
    
            'End If
        End Sub
    I commented most of that out, so ignore the comments



    TryALetter is a sub that accepts a character. It finds all occurrences of the guessed letter

    in mWord and changes the “*”’s at the same location in mUncoveredLetter to the actual letter. (A useful method to use is .IndexOf, for example, mWord.IndexOf(chrGuessLetter) returns the location of the character in the string. If a negative number is returned, the letter is not in the string.) If the letter is in the word, then you need to “uncover” it in mUncoveredWord. One way to do this is to create an array of characters and assign mUncoveredLetters to that array.

    That way you can loop through comparing each character in mWord (mWord.Chars(i)) to the guess letter and if it matches assign the letter to the same location in your UncoveredLetters array. Once you have processed the entire word, set mUncoveredLetters equal to the array in order to transfer the new set of letters back to the mUncoveredLetters variable. If the letter is not in your word at all, your program should increment HangmanImage by 1.


    1:delta> personally, i would not go to war for oil
    1:FarScape> in age of empires you would
    1:Freeze> LOL FAR
    ---
    5:waven> freeze
    5:waven> no one talks to ease directly
    5:waven> you state your business with sanji
    5:waven> he will relay it to phizey
    5:waven> phizey will relay it to me
    5:waven> and i will talk to ease
    5:Freeze> LOL
    5:waven> that's how things work around here
    --
    1:renzi> freeze theres difference between being wasted and being a waste

  • #2
    I fixed problem one

    strFileName += 1
    picHangman.Image = Image.FromFile(strFileName & ".jpg")

    by doing this in the form
    but it says picHangman is undeclared but it really isnt


    1:delta> personally, i would not go to war for oil
    1:FarScape> in age of empires you would
    1:Freeze> LOL FAR
    ---
    5:waven> freeze
    5:waven> no one talks to ease directly
    5:waven> you state your business with sanji
    5:waven> he will relay it to phizey
    5:waven> phizey will relay it to me
    5:waven> and i will talk to ease
    5:Freeze> LOL
    5:waven> that's how things work around here
    --
    1:renzi> freeze theres difference between being wasted and being a waste

    Comment


    • #3
      Sucks for you that I'm in your class =/

      Comment

      Working...
      X