Skip to content

Instantly share code, notes, and snippets.

@caisback
Created October 1, 2022 10:58
Show Gist options
  • Save caisback/a3f0ea003fecd27f3cd93f07004fdad8 to your computer and use it in GitHub Desktop.
Save caisback/a3f0ea003fecd27f3cd93f07004fdad8 to your computer and use it in GitHub Desktop.
VB.Net - Windows - Object Centering
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        'btnCenter.Location = New Point((Me.Width / 2) - (btnCenter.Width / 2), btnCenter.Location.Y)

        btnCenter.Location = New Point((Me.Width / 2) - (btnCenter.Width / 2), (Me.Height / 2) - (btnCenter.Height / 2))

        tbCenter.Location = New Point((Me.Width / 2) - (tbCenter.Width / 2), tbCenter.Location.Y)

        'btnCenter.Location = New Point(Int32.Parse((Me.Width / 2) - (btnCenter.Width / 2)), btnCenter.Location.Y)
    End Sub
End Class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment