I'm really confused on when a ByRef and a ByVal should be used. I've been told that a Function should always return a value where as a Sub doesn't have to/can return multiple values. However, I'm really stuck on when I should use ByRef and ByVal.
Function Check(ByRef valid As Boolean, ByVal prize As Integer) As Boolean
If prize < 1000000 Or prize > 4000000 Then valid = False
Return valid
End Function
For example, above, I need valid to be changed by the Function, but if I used ByVal, it wouldn't change it as ByVal's don't keep the change of the value and pass it back. Please help, tyvm.