4.9 By-Value en By-Reference
{"Image DocumentName": "4.9 By-Value en By-Reference", "Image ImageDescription": "1 ByRefTest.vb. 2 Demonstrates passing by reference Module modByRefTest squares three values ByVal and ByRef, displays results. 7 Sub Main() 8 Dim number1 As Integer = Console.WriteLine( Passing a value-type argument by value: ) 11 Console.WriteLine( Before calling SquareByValue, & _. 12 number1 is {0} , number1) 13 SquareByValue(number1) passes number1 by value. 14 Console.WriteLine( After returning from SquareByValue, & _. 15 number1 is {0} & vbCrLf, number1) Dim number2 As Integer = Console.WriteLine( Passing a value-type argument & _. 20 by reference: ) 21 Console.WriteLine( Before calling SquareByReference, & _. 22 number2 is {0} , number2) 23 SquareByReference(number2) passes number2 by reference. 24 Console.WriteLine( After returning from & _. 25 SquareByReference, number2 is {0} & vbCrLf, number2) Dim number3 As Integer = Een copie van de waarde wordt doorgegeven aan de procedure. Een verwijzing naar de waarde wordt doorgegeven. Programma geeft 3 waarden door. - 1 by val => Na uitvoering procedure bevat number nog steeds dezelfde waarde. - 1 by ref => na uitvoering procedure is de waarde van variabele number aangepast. - 1 waarvan argument tussen haakjes (dus toch byref) Visual Basic.NET.", "Image XResolution": "37", "Image YResolution": "37", "Image ResolutionUnit": "Pixels/Centimeter", "Image Software": "SlidePlayer", "Image YCbCrPositioning": "Centered"}