Results 1 to 25 of 25

Thread: [RESOLVED] Picture Box Issue

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,638

    Re: Picture Box Issue

    Code:
    pboxHangman.ImageLocation = "Images \ Hangman-  & numWrongGuesses & .png"
    Anything inside of quotes is treated literally. So, given the following code:

    Code:
    Dim strMyMessage As String = "Hello!"
    Dim intMyNumber As Integer = 1
    
    MessageBox.Show("strMyMessage")
    MessageBox.Show(strMyMessage)
    MessageBox.Show("intMyNumber.ToString")
    MessageBox.Show(intMyNumber.ToString)
    Would pop up messages in the following order:

    Code:
    strMyMessage
    Hello!
    intMyNumber.ToString
    1
    From this, you can see that including a variable name inside of quotes does not result in the value stored in that variable to be used.

    To demonstrate this, take the path you are trying to use to load an image from, and pop it into a MessageBox statement:

    Code:
    MessageBox.Show("Images \ Hangman-  & numWrongGuesses & .png")
    You should see that what is displayed is probably not the intended path to one of your image files.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Picture Box Issue

    Quote Originally Posted by OptionBase1 View Post
    Code:
    pboxHangman.ImageLocation = "Images \ Hangman-  & numWrongGuesses & .png"
    Anything inside of quotes is treated literally. So, given the following code:

    Code:
    Dim strMyMessage As String = "Hello!"
    Dim intMyNumber As Integer = 1
    
    MessageBox.Show("strMyMessage")
    MessageBox.Show(strMyMessage)
    MessageBox.Show("intMyNumber.ToString")
    MessageBox.Show(intMyNumber.ToString)
    Would pop up messages in the following order:

    Code:
    strMyMessage
    Hello!
    intMyNumber.ToString
    1
    From this, you can see that including a variable name inside of quotes does not result in the value stored in that variable to be used.

    To demonstrate this, take the path you are trying to use to load an image from, and pop it into a MessageBox statement:

    Code:
    MessageBox.Show("Images \ Hangman-  & numWrongGuesses & .png")
    You should see that what is displayed is probably not the intended path to one of your image files.
    okay... This is the location to the Images Folder C:\Users\ENJ1105\source\repos\HangmanApp\HangmanApp\Resources\Images

    Here are my instructions...

    A PictureBox control that will display the hangman images. You’ll set the ImageLocation property to load the hangman images.

    Check to see if the word (word) contains the guess (txtGuess).
    If it does, then call the SetRightLetterLabels method (provided below) and increment the numRightGuesses variable.
    If it doesn’t, set the image in the pboxHangman and increment the numWrongGuesses variable.
    Your code should resemble the following:
    pboxHangman.ImageLocation = “images\Hangman-” &
    numWrongGuesses & “.png”
    numWrongGuesses += 1

  3. #3
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,638

    Re: Picture Box Issue

    Quote Originally Posted by EmilyM1105 View Post
    Your code should resemble the following:
    pboxHangman.ImageLocation = “images\Hangman-” & numWrongGuesses & “.png”
    Does your code resemble that? If not, then that's probably a good place to start.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width