منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
تحريك العناصر الى كل الاتجاهات - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : تحريك العناصر الى كل الاتجاهات (/showthread.php?tid=17757)



تحريك العناصر الى كل الاتجاهات - bidaya - 23-10-16

هذا الكود الموجود في المشاركة 
كود :
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

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


RE: تحريك العناصر الى كل الاتجاهات - جوري - 24-10-16

(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



RE: تحريك العناصر الى كل الاتجاهات - bidaya - 27-10-16

شكرا لك اخي الكود تمام التمام الله يرضى عليك وان يجعلها لك في ميزان الحسنات


RE: تحريك العناصر الى كل الاتجاهات - bahgat okasha - 23-11-16

يمكنك أيضا عكسها بكود أسهل وأبسط
p1.top-= 4
p2.top+= 4