by john tomson (9 Submissions)
Category: Miscellaneous
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Fri 18th November 2005
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
make a commandbutton move
API Declarations
commandbutton called commandbutton1
form called userform1
If TextBox1.Text = "a" And commandbutton1.Left >= 0 Then
commandbutton1.Left = commandbutton1.Left - 5
TextBox1 = ""
ElseIf TextBox1.Text = "d" And commandbutton1.Left <= 216 Then
commandbutton1.Left = commandbutton1.Left + 5
TextBox1 = ""
ElseIf TextBox1.Text = "w" And commandbutton1.Top >= 0 Then
commandbutton1.Top = commandbutton1.Top - 5
TextBox1 = ""
ElseIf TextBox1.Text = "s" And commandbutton1.Top <= 216 Then
commandbutton1.Top = commandbutton1.Top + 5
TextBox1 = ""
Else: TextBox1.Text = ""
End If
End Sub
Private Sub UserForm_initialize()
commandbutton1.Enabled = False
commandbutton1.Caption = ""
commandbutton1.BackColor = &HFF00&
TextBox1.Height = 1
TextBox1.Width = 1
UserForm1.BackColor = &H80000012
MsgBox "--Movement Keys-- a=left | d=right | w=up | s=down"
End Sub