樱井步2016番号及封面:vb的LEFT跟TOP问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/05 19:10:21
Dim x As Integer
Private Sub Form_Click()
Command1.Left = Command1.Left + x
If Command1.Left = Command2.Left Then
If Command1.Top = Command2.Top Then
x = -x
End If
End If
End Sub

Private Sub Form_Load()
x = 500
End Sub

现在这个要完全重叠才能反弹
怎么能够张command1 跟command2重叠小小就能反弹呢
都不对啊 我现在知道怎么搞了是VB爱好者就加15706055这个群我说给大家听

Dim x As Integer
Private Sub Form_Click()
Command1.Left = Command1.Left + x
If Command1.Left = Command2.Left - Command2.Width Then
If Command1.Top = Command2.Top Then
x = -x
End If
End If
End Sub

Private Sub Form_Load()
Command1.Left = 0
Command2.Left = 4000
Command1.Top = 300
Command2.Top = 300
Command1.Width = 500
Command2.Width = 500
Command1.Height = 300
Command2.Height = 300
x = 500
End Sub

If Command1.Left = Command2.Left or Command1.Top = Command2.Top Then
x = -x
End If
End Sub