Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.88 KB

File metadata and controls

43 lines (34 loc) · 1.88 KB
title ByVal (Visual Basic)
ms.date 07/20/2015
ms.prod .net
ms.suite
ms.technology
devlang-visual-basic
ms.topic article
f1_keywords
vb.ByVal
ByVal
helpviewer_keywords
ByVal keyword [Visual Basic], contexts
ByVal keyword [Visual Basic]
ms.assetid 1eaf4e58-b305-4785-9e3d-e416b9c75598
caps.latest.revision 14
author dotnet-bot
ms.author dotnetcontent

ByVal (Visual Basic)

Specifies that an argument is passed in such a way that the called procedure or property cannot change the value of a variable underlying the argument in the calling code.

Remarks

The ByVal modifier can be used in these contexts:

Declare Statement

Function Statement

Operator Statement

Property Statement

Sub Statement

Example

The following example demonstrates the use of the ByVal parameter passing mechanism with a reference type argument. In the example, the argument is c1, an instance of class Class1. ByVal prevents the code in the procedures from changing the underlying value of the reference argument, c1, but does not protect the accessible fields and properties of c1.

[!code-vbVbVbalrKeywords#10]

See Also

Keywords
Passing Arguments by Value and by Reference