| title | ByVal (Visual Basic) | ||
|---|---|---|---|
| ms.date | 07/20/2015 | ||
| ms.prod | .net | ||
| ms.suite | |||
| ms.technology |
|
||
| ms.topic | article | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | 1eaf4e58-b305-4785-9e3d-e416b9c75598 | ||
| caps.latest.revision | 14 | ||
| author | dotnet-bot | ||
| ms.author | dotnetcontent |
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.
The ByVal modifier can be used in these contexts:
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]