请问怎样才能使程序启动时窗体始终居中?

解决方案 »

  1.   

    将窗体的StartUpPosition属性设为2
      

  2.   

    将窗体的StartUpPosition属性设为2或者Private Sub Form_Load()
        Me.Left = (Screen.Width - Me.Width) \ 2
        Me.Top = (Screen.Height - Me.Height) \ 2
    End Sub
      

  3.   

    或者
    Private Sub Form_Load()
    Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
    End Sub
      

  4.   

    一般将窗体的StartUpPosition属性设为2
      

  5.   

    窗体属性:StartUpPosition
    返回或设置一个值,指定对象首次出现时的位置,运行时不能使用。
    常数 值 描述 
    vbStartUpManual 0 没有指定初始设置值。 
    vbStartUpOwner 1 UserForm 所属的项目中央。 
    vbStartUpScreen 2 屏幕中央。 
    vbStartUpWindowsDefault 3 屏幕的左上角。 
      

  6.   

    最好是Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2