0

所以我试图在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

好吧,那是行不通的。我该怎么做才能让它发挥作用?谢谢!

4

1 回答 1

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
于 2012-11-22T05:58:49.323 回答