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

[µo°Ý] ByVal Target As Range ¥Îªk

¦^´_ 4# c_c_lai
jackyq ®v¥S,ÁÂÁ§A¦³¥Îªº¸ê®Æ
cc lai ÁÂÁ§A¥J²Ó´£¨Ñªºsample, ¦ý¦]¬°§Ú³£¤ñ¸ûÄø,§Ú·Q°Ý¦h¤Ö¤Ö,byref §Ú³£¤j¬ùª¾¹DÊ\¬J¥Îªk,Ê\«Y·|§ïÅܭ즳¼Æ­Èªº­È,

¦ý¬Obyval Ê\«Yªk«Y­ø·|§ïÅÜ­ÓÅÜ¥»¨­­ì¦³¬J¼Æ­È,ËÝ­n³]©wbyval ¦³¤°»ò§@¥Î©O??

ÁÂÁÂ

TOP

¦^´_ 4# c_c_lai
ÁÂÁ¤À¨É!!

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2016-1-28 16:07 ½s¿è

¦^´_ 1# mdr0465
Á|­Ó¹ê¨Ò»¡©ú¡A§A«K·|©úÁA¡G
  1. Sub joke()
  2.     Dim txt As String, num As Integer
  3.    
  4.     txt = "§A¦n¶Ü¡H": num = 200
  5.     Test1 txt, num    '  ¶Ç§}  (§Y jackyq ¤j¤j¤À¨Éªº "¥»´L")
  6.     MsgBox "txt = " & txt & " , num = " & num
  7.     '  µª®×¬O¡G txt = «Ü¦n¡AÁÂÁ¡I ¤j®a¥i¦n? , num = 150
  8.    
  9.     txt = "¦­À\¦Y¤F¶Ü¡H": num = 100
  10.     Test2 txt, num     '  ¶Ç­È  (§Y jackyq ¤j¤j¤À¨Éªº "¤À¨­")
  11.     MsgBox "txt = " & txt & " , num = " & num
  12.     '  µª®×¬O¡G txt = ¦­À\¦Y¤F¶Ü¡H , num = 100
  13. End Sub

  14. Sub Test1(ByRef txt As String, ByRef num As Integer)   '  ¶Ç§} (¦ì§} Address)
  15.     txt = "«Ü¦n¡AÁÂÁ¡I ¤j®a¥i¦n?"                      '   (Reference)
  16.     num = num - 50
  17. End Sub

  18. Sub Test2(ByVal txt As String, ByVal num As Integer)   '  ¶Ç­È  (¼Æ­È Value)
  19.     txt = "«D±`¦n¡I§B¤÷¨­Åé¦n»ò¡H"
  20.     num = num - 85
  21. End Sub
½Æ»s¥N½X

TOP

byval object =byref object = objectªº¥»´L
byval ÅܼÆa = ÅܼÆaªº¤À¨­
byref ÅܼÆa = ÅܼÆaªº¥»´L

TOP

¦^´_ 1# mdr0465
¦h¦h¤Wºô¬d¸ß¡A§A«K·|§ó¥[©úÁA¥~­±ªº¥@¬É¤F¡C
¥H ByVal ©M ByRef ¶Ç»¼¤Þ¼Æ

ByRef and ByVal Parameters

TOP

        ÀR«ä¦Û¦b : ¤Hªº²´·úªø¦b«e­±¡A¥u¬Ý¨ì§O¤Hªº¯ÊÂI¡Aµ·²@¬Ý¤£¨ì¦Û¤vªº¯ÊÂI¡C
ªð¦^¦Cªí ¤W¤@¥DÃD