Methods Arguments: ByVal and ByRef

Methods can receive parameters and can then work with data provided by parameters. In the .NET terminology, parameters are also known as arguments. We mainly use the word arguments because it’s the one that you typically find within the documentation and about topics related to .NET development. The following code shows a simple sample of a method definition receiving an argument and subsequent invocation of that method passing an argument:

image

Arguments can be passed by value and by reference. You pass arguments by value adding the ByVal keyword, whereas you pass them by reference specifying the ByRef keyword. If ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.