这样一个问题,用键盘左右切换当前窗口的背景图片,设背景图片的总数是变量Num,切换到当前的画面名称是Num_i,
下面代码是自己编写,提示类型不匹配,请指教!
另有问题:这里是将背景图片存在PIC文件夹下,依次命名为1.jpg,2.jpg--Num.jpg,那么有没有什么方法可以不这么命名达到动态更改显示的效果?
Dim Num As Integer
Dim Num_i As Integer
Private Sub Form_Load()
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print KeyCode
If (KeyCode = 37) Then
Dim i As Integer
For i = 0 To Num
If (i = 1) Then
Me.Picture = LoadPicture(App.Path & "\PIC\" + Num + ".jpg")
Else
Num_i = Num_i - 1
Me.Picture = LoadPicture(App.Path & "\PIC\" + Num_i + ".jpg")
End If
Next
End If
If (KeyCode = 39) Then
If (i = Num) Then
Me.Picture = LoadPicture(App.Path & "\PIC\1.jpg")
Else
Num_i = Num_i + 1
Me.Picture = LoadPicture(App.Path & "\PIC\" + Num_i + ".jpg")
End If
End If
End Sub