使用With...End With

With...End With允许对指定的对像执行一系列语句,而不必重新限定对象的名称!

  基本用法:

   With object

   [statements]

  End with


      举例如下:

  With Me.TextBox1
            .Text = "Text with...end with"
            .TextAlign = HorizontalAlignment.Center
            .BorderStyle = BorderStyle.None
            .AutoSize = True
        End With

  with... end with的嵌套

  With Me.TextBox1
            .Text = "Text with...end with" 
     .TextAlign = HorizontalAlignment.Center 
     .BorderStyle = BorderStyle.None
     .ReadOnly = True
            With Me
                .StartPosition = FormStartPosition.CenterScreen
                .MaximizeBox = False
                .MinimizeBox = False
                .Opacity = 50%
                .FormBorderStyle = FormBorderStyle.FixedSingle
                .ShowInTaskbar = False
            End With
        End With

posted @ 2006-07-14 11:29  dodo-yufan  阅读(375)  评论(0编辑  收藏  举报