VB.net 标签沿着窗口边沿顺时针移动
如题,刚开始学我只能做到将标签沿窗口上沿从左到右移动但是到了右侧边沿无法停止让标签向下移动95求大神帮忙解决一下dhlp谢谢这个完整的程序,即沿边沿顺时针移动517最好带...
如题,刚开始学我只能做到将标签沿窗口上沿从左到右移动但是到了右侧边沿无法停止让标签向下移动95求大神帮忙解决一下dhlp谢谢这个完整的程序,即沿边沿顺时针移动517最好带个注释 谢谢
展开
展开全部
'窗体放置Panel1 ,Label1,Timer1控件各一个 Label1置于Panel1中
Dim Label_X As Integer
Dim Label_Y As Integer
Dim Panel_W As Integer
Dim Panel_H As Integer
Dim Label_W As Integer
Dim Label_H As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Panel1.Dock = DockStyle.Fill
Timer1.Start()
Label_X = 0
Label_Y = 0
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Panel_W = Panel1.Width
Panel_H = Panel1.Height
Label_W = Label1.Width
Label_H = Label1.Height
Label1.Location = New Point(Label_X, Label_Y) '设置控件新坐标
If Label_Y = 0 Then
Label_X = Label_X + 5 '5=每次位移距离
End If
If Label_X >= Panel_W - Label_W Then
Label_Y = Label_Y + 5
End If
If Label_Y >= Panel_W - Label_W Then
Label_X = Label_X - 5
End If
If Label_X = 0 Then
Label_Y = Label_Y - 5
End If
End Sub
Dim Label_X As Integer
Dim Label_Y As Integer
Dim Panel_W As Integer
Dim Panel_H As Integer
Dim Label_W As Integer
Dim Label_H As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Panel1.Dock = DockStyle.Fill
Timer1.Start()
Label_X = 0
Label_Y = 0
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Panel_W = Panel1.Width
Panel_H = Panel1.Height
Label_W = Label1.Width
Label_H = Label1.Height
Label1.Location = New Point(Label_X, Label_Y) '设置控件新坐标
If Label_Y = 0 Then
Label_X = Label_X + 5 '5=每次位移距离
End If
If Label_X >= Panel_W - Label_W Then
Label_Y = Label_Y + 5
End If
If Label_Y >= Panel_W - Label_W Then
Label_X = Label_X - 5
End If
If Label_X = 0 Then
Label_Y = Label_Y - 5
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询