ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¶Ç­È©I¥s(Call By Value)

[µo°Ý] ¶Ç­È©I¥s(Call By Value)

¤U¦C¬O¥Îcall By Valueªºµ{¦¡½X¡AÅã¥Üªº¼Æ­È¬O10¡A§Ú·Q½Ð°Ý¤@¤U¦U¦ì´N¬Oa¨S¦³«Å§i,¨ºa¬Oxªº½Æ»s­È¶Ü¡Hsub¨ºÃ䤣¤Ó¤F¸Ñ¡H§Æ±æ¦³¥ý¶i¸ÑÄÀ¤@¤U
Module Module1

    Sub Main()
        Dim x As Integer = 10
        Call Square(x)
        Console.WriteLine(x)
        Console.ReadKey()
    End Sub
    Sub Square(ByVal a As Integer)
       a = a ^ 2
    End Sub

End Module

ÅܼÆa ¬O¦³«Å§i³á!
Sub Square(ByVal a As Integer) '«Å§iaÅܼƬ°¼Æ­È¡AByVal «h¬OµL¦^¶Ç­È¡C

ex1
Sub Main()
Dim x As Integer = 10
Call Square(x)
msgbox.show(x)'ÁÙ¬O10
End Sub

Sub Square(ByVal a As Integer)
a = a +a
End Sub


ex2
Sub Main()
Dim x As Integer = 10
Call Square(x)
msgbox.show(x)'¦^¶ÇSquare¹Bºâ¹Lªº­È¡Aµ¥©ó20¡C
End Sub

Sub Square(Byref a As Integer)
a = a +a
End Sub
­Y¬O§Ú¦^µª¡A¨Ï±zº¡·N¡A½Ð±zÅý§Úª¾¹D¡I                  
­Y¬O§Úªº¦^ÂСA±z¤´¦³¨ä¥L¨£¸Ñ¡A¤]½Ð±z¤£¶Þ«ü±Ð¡I

TOP

        ÀR«ä¦Û¦b : ¯à·F¤£·F¡A¤£¦p­W·F¹ê·F¡C
ªð¦^¦Cªí ¤W¤@¥DÃD