Form窗体有一个属性是StartPosition,把它设置为CenterScreen就是居中。
代码为 Me.StartPosition = FormStartPosition.CenterScreen。
如果是非要计算分辨率的话:
My.Computer.Screen.Bounds.Width 是分辨率中的宽度
My.Computer.Screen.Bounds.Height 是分辨率中的高度
那么
Me.Top = (My.Computer.Screen.Bounds.Height - Me.Height) / 2
Me.Left = (My.Computer.Screen.Bounds.Width - Me.Width) / 2
就是让窗体居中啦~
Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Me.Top = (My.Computer.Screen.Bounds.Height - Me.Height) / 2 Me.Left = (My.Computer.Screen.Bounds.Width - Me.Width) / 2 ‘Me.StartPosition = FormStartPosition.CenterScreen ‘Me.Left = 0 : Me.Top = 0 ‘Me.Width = My.Computer.Screen.Bounds.Width ‘是分辨率中的宽度 ‘Me.Height = My.Computer.Screen.Bounds.Height ‘是分辨率中的高度 End Sub End Class