Advertisement
hectic101

Reference paremeters

Apr 12th, 2015
1,747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option VBASupport 1
  2. Option Explicit
  3.  
  4. Sub Main
  5.     Dim y As Double
  6.    
  7.     y = 10
  8.     halve1 y
  9.     MsgBox " y = " & y
  10. End
  11.  
  12. Sub halve1(ByVal x As Double) 'copies the value of y into x but doesn't change the value of x
  13.     x = x/2
  14. End Sub
  15.  
  16. Sub halve2(ByRef c As Double) 'x as the re3ference but changes the value of y
  17.     x = x/2
  18. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement