Home » VB.NET With and With Statement

VB.NET With and With Statement

by Online Tutorials Library

VB.NET With End With Statement

In VB.NET, the With End statement is not the same as a loop structure. It is used to access and execute statements on a specified object without specifying the name of the objects with each statement. Within a With statement block, you can specify a member of an object that begins with a period (.) to define multiple statements.

Syntax:

objExpression: It defines the data type of objExpression. It may be any class or structure type or basic data type such as Integer. It can be executed once in the With End statement.

Statement: It defines one or more executed statements within the With block. The statement refers to the member of the object that links with objectExpression to execute the With statement block.

End With: It is used to end the With block.

Example: Write a program to understand the uses of With End statement in VB.NET.

Employee.vb

Output:

VB.NET With End With Statement

Example: Write a program to display the student details using the With End statement in VB.NET.

With_Statement.vb

Output:

VB.NET With End With Statement


You may also like