Hi
Im not sure if this is a problem or not. Could someone explain
this to me?
The following function is called from VB and the string
being passed in the Text argument = ""
Obviously the problem is a result of the dynamic string's length
not being updated when MoveMemory is used on it and can be
worked around by just using Space$() on the string ahead of time.
But is this normal behavior? I tested this scenario under VB and
the strings length is correctly updated after the MoveMemory
operation.
But it seems odd that Msgbox would show "Hello" at all. Sorta
like "now you see it, now you dont." It also seems odd that
when actually assigning Text to s1, that s1 takes on the exact
characteristics of Text.
Just to be clear, this isnt an issue for me since i now just
use Space$() to presize the string. Im just posting this message
for clarification whether this is a bug or by design.
Thanks
-Mike
[This message has been edited by Mike Joseph (edited August 28, 2000).]
Im not sure if this is a problem or not. Could someone explain
this to me?
The following function is called from VB and the string
being passed in the Text argument = ""
Code:
Function PassStringByRef (ByRef Text as string) Export as Long Dim s1 as string Dim s2 as string s1 = "Hello" MoveMemory STRPTR(Text), STRPTR(s1), Len(s1) Msgbox Text ' <-- Produces "Hello" in message box Text = Text & " added" ' <-- Produces " added" in message box s2 = Text MSGBOX s2 ' <-- Produces "Hello" in message box s2 = s2 & " added" Msgbox s2 ' <-- Produces " added" in message box Functon = 0 ' <-- The results of Text back on the VB side = "" End Function
not being updated when MoveMemory is used on it and can be
worked around by just using Space$() on the string ahead of time.
But is this normal behavior? I tested this scenario under VB and
the strings length is correctly updated after the MoveMemory
operation.
But it seems odd that Msgbox would show "Hello" at all. Sorta
like "now you see it, now you dont." It also seems odd that
when actually assigning Text to s1, that s1 takes on the exact
characteristics of Text.
Just to be clear, this isnt an issue for me since i now just
use Space$() to presize the string. Im just posting this message
for clarification whether this is a bug or by design.
Thanks
-Mike
[This message has been edited by Mike Joseph (edited August 28, 2000).]
Comment