Difference between ByVal and ByRef?

后端 未结 9 2304
囚心锁ツ
囚心锁ツ 2020-12-15 19:34

What is the difference? I always use ByVal, but, I don\'t really have a good idea of when should I and when not...

9条回答
  •  隐瞒了意图╮
    2020-12-15 20:12

    I hope this answers your question

    Sub last_column_process()
    Dim last_column As Integer
    
    last_column = 234
    MsgBox last_column
    
    trying_byref x:=last_column
    MsgBox last_column
    
    trying_byval v:=last_column
    MsgBox last_column
    
    End Sub
    
    Sub trying_byref(ByRef x)
    x = 345
    End Sub
    
    Sub trying_byval(ByRef v)
    v = 555
    End Sub
    

提交回复
热议问题