|
-
Feb 21st, 2018, 03:41 PM
#1
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.
-
Feb 21st, 2018, 03:55 PM
#2
Thread Starter
Addicted Member
Re: Picture Box Issue
 Originally Posted by OptionBase1
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
-
Feb 21st, 2018, 04:01 PM
#3
Re: Picture Box Issue
 Originally Posted by EmilyM1105
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|