-
Why does the API CopyMemory behave in a variant of ways?
Eg
If I want to move a type to a string then I have to use
Code:
sTemp = Space$(Len(ETU7CallType))
CopyMemory ByVal sTemp, SomeCallType, Len(sTemp)
but if I want to copy a string to a type then I have to use
Code:
CopyMemory guETU7Type, ByVal sTGB, Len(guETU7Type)
I know there are reasons and I would just like to know why - cos I'm fed up of having to reload the project after vb crashes!
-
IT's crashes because you don't know how a string is stored. Strings in vb are unicode by default, so the memory space needed for a string is 2*the length of the string. Therefore either convert the string first or feed a smaller string.
-
Knowledge
I know that byval sends the value of the stated variable, but that still hasn't really explained *why* in the first example the source is sent byref and not byval.