今回ホームページにテスト2として,アップロードした,VB6のプログラムのソースコードはこちらです.
test20190505_001ソースコード
-----------------------------------------------------------------------------------------------------------------
Form1.frmのソース
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4395
ClientLeft = 60
ClientTop = 345
ClientWidth = 6285
KeyPreview = -1 'True
LinkTopic = "Form1"
ScaleHeight = 4395
ScaleWidth = 6285
StartUpPosition = 3 'Windows の既定値
Begin VB.Image Image2
Height = 960
Left = 2760
Picture = "Form1.frx":0000
Top = 1800
Width = 480
End
Begin VB.Image Image1
Height = 7200
Left = 0
Picture = "Form1.frx":1842
Top = -240
Width = 9600
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
MsgBox "Esc終了"
a = 10000
Image2.Move (Image2.Left), (Image2.Top)
Form1.Show
Do
If a >= 10000 Then
If GetAsyncKeyState(vbKeyLeft) Then
Image2.Left = Image2.Left - 50
Image2.Move (Image2.Left), (Image2.Top)
a = 0
ElseIf GetAsyncKeyState(vbKeyRight) Then
Image2.Left = Image2.Left + 50
Image2.Move (Image2.Left), (Image2.Top)
a = 0
ElseIf GetAsyncKeyState(vbKeyUp) Then
Image2.Top = Image2.Top - 50
Image2.Move (Image2.Left), (Image2.Top)
a = 0
ElseIf GetAsyncKeyState(vbKeyDown) Then
Image2.Top = Image2.Top + 50
Image2.Move (Image2.Left), (Image2.Top)
a = 0
ElseIf GetAsyncKeyState(vbKeyEscape) Then
Call Unload(Me)
Exit Do
End If
End If
Form1.Show
Do
a = a + 1
If a >= 10000 Then
Exit Do
End If
Loop
Loop
End Sub
----------------------------------------------------------------------------------------------------------------
Module1.basのソース
Attribute VB_Name = "Module1"
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
------------------------------------------------------------------------------------------------------------------
以上