Sabtu, 04 Oktober 2014

“Event Keyboard” dengan Visual Basic 6.0

VB6SP6_logo

Percontohan “Event Keyboard” yang terdapat pada blog “Ketik Visual Basic!”.

Tidak ada modifikasi yang dibuat. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan.

 

 

 

Event_Keyboard

VERSION 5.00
Begin VB.Form Form1
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Caption = "Kejadian Pada Papan Ketik"
ClientHeight = 3120
ClientLeft = 45
ClientTop = 405
ClientWidth = 4680
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3120
ScaleWidth = 4680
StartUpPosition = 2 'CenterScreen
Begin VB.Shape Shape1
BackColor = &H00000000&
BackStyle = 1 'Opaque
BorderColor = &H00FFFFFF&
Height = 855
Left = 1493
Shape = 3 'Circle
Top = 1133
Width = 1695
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_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
Call Bergerak_Ke_Kiri
Case vbKeyRight
Call Bergerak_Ke_Kanan
End Select
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then
If MsgBox("Tutup animasi ?", vbQuestion + vbYesNo, _
Me.Caption) = vbYes Then End
End If
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyUp
Call Bergerak_Ke_Atas
Case vbKeyDown
Call Bergerak_Ke_Bawah
End Select
End Sub

Private Sub Bergerak_Ke_Kiri()
PosisiX = PosisiX - 10
If PosisiX < 0 Then
PosisiX = 0
End If
Shape1.Move PosisiX
End Sub

Private Sub Bergerak_Ke_Kanan()
PosisiX = PosisiX + 10
If PosisiX > Me.ScaleWidth - Shape1.Width Then
PosisiX = Me.ScaleWidth - Shape1.Width
End If
Shape1.Move PosisiX
End Sub

Private Sub Bergerak_Ke_Atas()
PosisiY = PosisiY - 10
If PosisiY < 0 Then
PosisiY = 0
End If
Shape1.Move PosisiX, PosisiY
End Sub

Private Sub Bergerak_Ke_Bawah()
PosisiY = PosisiY + 10
If PosisiY > Me.ScaleHeight - Shape1.Height Then
PosisiY = Me.ScaleHeight - Shape1.Height
End If
Shape1.Move PosisiX, PosisiY
End Sub


Unduh Kode Sumber

Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda