Nested With statement : With statement « Statements « VB.Net Tutorial






Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1 : Inherits Form
   Public Shared Sub Main()
      Dim frm As New Form1()
      Application.Run(frm)
   End Sub

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      With Me
         .BackColor = Color.Gray
         .ForeColor = Color.Red
         .Text = "The With Statement"
         .Enabled = True
         .TopMost = True
         .MinimizeBox = False
         For Each ctrl As Control In .Controls
            With ctrl
               .BackColor = SystemColors.Window
               .AutoSize = False
               .Cursor = Cursors.Hand
            End With
         Next
      End With
   End Sub
End Class








4.5.With statement
4.5.1.Use With statement with Form object
4.5.2.Insert statement into With statement
4.5.3.Nested With statement
4.5.4.Use With statement with OpenFileDialog