所以我试图在VB6中只用一张图像制作这个表格,每当你按下“Q”键时图像就会改变,如果你按下“E”,它就会变回上一个。简单的东西。
这就是我所拥有的:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 81 Then Image.Picture = LoadPicture("E:\Imagenes\Avatars\4.jpg")
If KeyAscii = 69 Then Image.Picture = LoadPicture("E:\Imagenes\Avatars\3.gif")
End Sub
嗯,这不起作用。我能做些什么才能让它发挥作用?谢谢!
答案 0 :(得分:0)
在阅读评论时,您说您使用的是默认图像控件,没有默认图像控件,您需要将其实例添加到表单或只使用表单图片属性。
这些例子对我有用:
Private Sub Form_KeyPress(KeyAscii As Integer)
If (Chr(KeyAscii) = "Q" Or Chr(KeyAscii) = "q") Then Form1.Picture = LoadPicture("E:\Imagenes\Avatars\4.jpg")
If (Chr(KeyAscii) = "E" Or Chr(KeyAscii) = "e") Then Form1.Picture = LoadPicture("E:\Imagenes\Avatars\3.gif")
End Sub
和
Private Sub Form_KeyPress(KeyAscii As Integer)
If (Chr(KeyAscii) = "Q" Or Chr(KeyAscii) = "q") Then Image1.Picture = LoadPicture("E:\Imagenes\Avatars\4.jpg")
If (Chr(KeyAscii) = "E" Or Chr(KeyAscii) = "e") Then Image1.Picture = LoadPicture("E:\Imagenes\Avatars\3.gif")
End Sub