Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable as a reference or value to a function
#18
(07-18-2022, 03:38 PM)mdijkens Wrote: The reason your initial code passes by value to the sub is the use of double brackets
Call MySub(a) ' passes reference to a
Call MySub((a)) ' evaluates (a) to tempvalue and passes reference to tempvalue

(Same is true for Functions btw)

btw i prefer to write (and read):
MySub a 'byref
MySub (a) 'byval
I don't think that enclosing the argument in parenthesis forces the argument to be treated as by value, at least not in the code I am trying to debug
honestly, why in the world doesn't QB64 have byval and byref for arguments to sub's and functions?
in another thread I posted a portion of Treebeards string math routines, the basic 4 functions seem to work but the Sqr function and the trig functions don't work, tried it in VB.net and at first I was getting no result until I changed the parameters that I could guess were meant to be modified to byref, then all the functions worked including the Sqr, logs and trigs
Reply


Messages In This Thread
RE: Variable as a reference or value to a function - by Jack - 08-08-2022, 02:14 PM



Users browsing this thread: 6 Guest(s)