muyBN was telling us:
muyBN nous racontait que :
I originally made this post over a year ago but thought I would
revisit it with some new information I found out that might be
helpful to other people.
I don't know if this happens in 100% of the cases, but I found that
in a function I was running, when I passed a parameter that had a
null value before returning the main value of the function, that the
value generated for the parameter in the function was also generated.
For example:
intInteger 'with null value
strString 'with null value
strValue = GetFunction(intInteger,strString) 'parameters intInteger
and strString are used in function
'after function returns a value for strValue, the previously
null-valued intInteger and strString now have a value as well, as
generated during GetFunction
This is because ByRef is the default value for passing arguments. In other
words, the argument may change the original variable value if it gets
modified in the function that uses it.
If you do not want that behaviour, you have to specify ByVal, as in:
Function GetFunction(ByVal intInteger As Long, ByVal strString As String)
Notice that I have declared the variable type, which I believe is a good
habit.
Also, I see you intend to use an Integer, but if you do, the compiler will
convert it to a Long because the smallest memory space a 32 bit computer can
allocate is equivalent to a long. So I do not use the Integer type anymore
as it does not save memory space and actually makes the execution marginally
slower because a conversion has to occur.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org