Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

[RESOLVED] Centering a form on screen

$
0
0
Im trying to center a form with 'animation' but the form keeps going to different location every time. heres the code I used

Code:

Dim ToLocX as integer = 0
Dim ToLocY as integer = 0
Dim LocX as integer = 0
Dim LocY as integer = 0

form load
ToLocX = Screen.PrimaryScreen.Bounds. Size.Height / 2
ToLocY = Screen.PrimaryScreen.Bounds. Size.Width / 2

timer
LocX = Me.Location.X
LocY = Me.Location.Y
If Not LocX = ToLocX And Not LocY = ToLocY
If LocX > ToLocX Then
LocX -= 1
Else
LocX += 1
End
If LocY > ToLocY Then
LocY -= 1
Else
LocY += 1
End If
Me.Location = New Point(LocX. LocY)
End If

IM TYPING FROM A PHONE

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>