#Byval vs. ref for DLL's
04-Oct-91 13:19:04
Sb: #1355-#Byval vs. ref for DLL's
Fm: Jim Mack 76630,2012
To: Clifford Barnett 70244,2755
Cliff –
Yes, unfortunately VB uses ByVal to mean two different things… sort
of. ByVal for numbers does mean the actual value is passed, not a pointer
to it. But ByVal for strings passes a long pointer to a null-terminated
string. The term is still appropriate, though, because in both cases the
item passed has been "dereferenced". Numeric variables have only pointers,
which yield values when deref'd. But strings have handles, which yield
pointers when deref'd.
To pass a structure in a field which is properly "ByVal X$", just
change the Declare to read "X As Any". As long as the receiving procedure
knows what it's getting, you can pass just about anything. "As Any" passes
a long pointer to a variable (exactly what a ByVal string is).
— Jim
There is 1 Reply.