منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : تحريك العناصر الى كل الاتجاهات
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
هذا الكود الموجود في المشاركة 
كود :
Public Class Form1

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       If Timer1.Enabled Then
           Timer1.Stop()
       Else
           Timer1.Start()
       End If
   End Sub

   Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
       p1.Left -= 4
       p2.Left += 4
   End Sub

   Private Sub p1_Click(sender As Object, e As EventArgs) Handles p1.Click

   End Sub

   Private Sub p1_Move(sender As Object, e As EventArgs) Handles p1.Move

       If p1.Left <= p2.Right Then
           Timer1.Stop()
       End If
   End Sub
End Class

اريد عكس الطريقة اي من الاعلى والاسفل
جزاكم الله جيرا
(23-10-16, 09:05 PM)bidaya كتب : [ -> ]هذا الكود الموجود في المشاركة 
كود :
Public Class Form1

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       If Timer1.Enabled Then
           Timer1.Stop()
       Else
           Timer1.Start()
       End If
   End Sub

   Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
       p1.Left -= 4
       p2.Left += 4
   End Sub

   Private Sub p1_Click(sender As Object, e As EventArgs) Handles p1.Click

   End Sub

   Private Sub p1_Move(sender As Object, e As EventArgs) Handles p1.Move

       If p1.Left <= p2.Right Then
           Timer1.Stop()
       End If
   End Sub
End Class

اريد عكس الطريقة اي من الاعلى والاسفل
جزاكم الله جيرا

تفضل التعديل اعلي واسفل
كود :
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If Timer1.Enabled Then
            Timer1.Stop()
        Else
            Timer1.Start()
        End If
    End Sub
    Dim location1 As New Point
    Dim location2 As New Point
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        location1.X = p1.Location.X 'المحور السيني
        location1.Y = p1.Location.Y - 1 'المحور الصادي
        p1.Location = location1

        'y - اعلي -
        'y+ اسفل
        '        -----------------------
        location2.X = p2.Location.X 'المحور السيني
        location2.Y = p2.Location.Y + 1 'المحور الصادي
        p2.Location = location2

   

    End Sub

    Private Sub p1_Click(sender As Object, e As EventArgs) Handles p1.Click

    End Sub

    'Private Sub p1_Move(sender As Object, e As EventArgs) Handles p1.Move

    '    If location1.Y <= location2.Y Then
    '        Timer1.Stop()
    '    End If
    'End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        If p1.Location.Y = p2.Location.Y Then
            Timer1.Stop()
        End If
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        Timer2.Start()
    End Sub
End Class
شكرا لك اخي الكود تمام التمام الله يرضى عليك وان يجعلها لك في ميزان الحسنات
يمكنك أيضا عكسها بكود أسهل وأبسط
p1.top-= 4
p2.top+= 4