With Statement

 <  Day Day Up  >  

The With statement simplifies repeatedly accessing the members of a value. Within a With statement, an expression beginning with just a period or an exclamation point is interpreted as if the With expression preceded it. For example:

 With TextBox1   .TabIndex = 0   .ForeColor = Color.Red   .Text = "Red"   .Show() End With 

The With expression is evaluated only once, at the beginning of the statement, so any changes to the underlying value of the With expression won't be applied until the With statement is reexecuted.

 With TextBox1   TextBox1 = New TextBox()   .TabIndex = 0   .ForeColor = Color.Red   .Text = "Red"   .Show() End With 

In this example, the original text box will be modified, even though the value in the TextBox1 variable has been changed.

 <  Day Day Up  >  


The Visual Basic .NET Programming Language
The Visual Basic .NET Programming Language
ISBN: 0321169514
EAN: 2147483647
Year: 2004
Pages: 173
Authors: Paul Vick

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net