hi to all,
i try to make to record and play command button movement programme in array i make it but record in listbox and i want to recoed it in array but i dont know how i record in array the value of x and y of command button plz any one hlep me isend my codings.
Public Class Form1
Dim dragging As Boolean
Dim mousex, mousey As Integer
'Dim x(10000) As Integer
'Dim y(10000) As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox1.Text = Windows.Forms.Cursor.Position.X
TextBox2.Text = Windows.Forms.Cursor.Position.Y
If dragging = True Then
ListBox1.Items.Add(TextBox1.Text)
'x(10000) = TextBox1.Text
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
'x(10000) += 1
ListBox2.Items.Add(TextBox2.Text)
'y(10000) = TextBox2.Text
ListBox2.SelectedIndex = ListBox2.SelectedIndex + 1
'y(10000) += 1
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim totalitems As Integer = ListBox1.Items.Count - 1
Dim selecteditems As Integer = ListBox1.SelectedIndex
If totalitems = selecteditems = False Then
Button3.Location = New Point(ListBox1.SelectedItem, ListBox2.SelectedItem)
'Button3.Location = New Point(x(10000), y(10000))
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
ListBox2.SelectedIndex = ListBox2.SelectedIndex + 1
'x(10000) += 1
'y(10000) += 1
Else
Timer2.Enabled = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer2.Enabled = False
Timer1.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
Timer2.Enabled = True
ListBox1.SelectedIndex = 0
ListBox2.SelectedIndex = 0
'x(10000) = 0
'y(10000) = 0
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End Sub
Private Sub Button3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button3.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
dragging = True
mousex = -e.X
mousey = -e.Y
Button3.Invalidate()
End If
End Sub
Private Sub Button3_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button3.MouseMove
If dragging Then
Dim MPosition As New Point()
MPosition = Me.PointToClient(MousePosition)
MPosition.Offset(mousex, mousey)
Button3.Location = MPosition
End If
End Sub
Private Sub Button3_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button3.MouseUp
If dragging Then
dragging = False
Windows.Forms.Cursor.Clip = Nothing
Button3.Invalidate()
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Timer1.Enabled = False
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
ListBox1.Items.Clear
ListBox2.Items.Clear()
End Sub
End Class