Keypress Issue
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Hey
I have 11 pictureboxes and on certain keypresses it puts pictures into the pictureboxes.
If i type HUNGRYHOUND it displays a picture in each picturebox depending on the key pressed.
**My problem is, If i type the same letter twice it does not appear, but leaves the picturebox blank, I know thats because i have already used it, But how do i code it to carry on accepting keys after they have been used?
If that makes sense
Chris
I have 11 pictureboxes and on certain keypresses it puts pictures into the pictureboxes.
If i type HUNGRYHOUND it displays a picture in each picturebox depending on the key pressed.
**My problem is, If i type the same letter twice it does not appear, but leaves the picturebox blank, I know thats because i have already used it, But how do i code it to carry on accepting keys after they have been used?
If that makes sense

Code: Select all
any help will be appreciated and + Reps given :P If e.KeyCode = Keys.H Then
PictureBox1.BackgroundImage = My.Resources.h
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
e.SuppressKeyPress = True
Chris
Have you tried to comment out the SuppressKeyPress line? I didn't think that it would affect later events but you can try.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

First of all set the form's KeyPreview property to true. You can do this from the property grid or adding the following code under the Form_Load event :
Code: Select all
Then change:
Form.KeyPreview = True
Code: Select all
To:
e.SuppressKeyPress = True
Code: Select all
And tell me if it works. Typed all of this from my mom's mobile lol :Pe.Handled = True
Instead of LOL use this -
LSIBMHBIWFETALOL
Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
LSIBMHBIWFETALOL
Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
Maybe you can create booleans to see if key was already pressed?
Then if you need put pictures and change bools...
Then if you need put pictures and change bools...
Ffenixw0rks wrote:Maybe you can create booleans to see if key was already pressed?I was having the same idea but that would take a lot of useless coding space and also slow down the program slightly. It would look stupid, lol.
I think it is better to use .image instead of .backgroundimage property, maybe they are the same, maybe not, idk. And are u using form.keydown or ?
What ffenix suggested wouldn't slow down the program, but it wouldn't solve the problem. M1z23r BackgroundImage and Image are two different things, but changing it wont have any visible effects.
I have no solution myself, it's a weird problem. The only thing I can think of is: hungryhound, do you use PictureBoxX.BackgroundImage.Dispose() at any point? If so, remove that line and it should work. Another tip; The SizeMode property only affects the drawing of the selected Image, not the BackgroundImage
I have no solution myself, it's a weird problem. The only thing I can think of is: hungryhound, do you use PictureBoxX.BackgroundImage.Dispose() at any point? If so, remove that line and it should work. Another tip; The SizeMode property only affects the drawing of the selected Image, not the BackgroundImage

LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

it's a weird problem. The only thing I can think of is: hungryhound, do you use PictureBoxX.BackgroundImage.Dispose() at any point? If so, remove that line and it should work. Another tip; The SizeMode property only affects the drawing of the selected Image, not the BackgroundImageHey
No i haven't used PictureBoxX.BackgroundImage.Dispose() in the coding
It's still a Mystery

Chris
Copyright Information
Copyright © Codenstuff.com 2020 - 2023