TypeToString Function in VB5

The TypeToString function uses the copytype.dll with the following parameters:  address of the type, return string, bytes to return.  For instance, I create a user-defined type that contains 3 variables, each of which are strings of 10 bytes.  When I call the TypeToString function, I will pass this type (automatically by reference), a string variable name, and 30 (number of bytes to return).  While I can use this function without issue in VB 3.0 and 4.0, I cannot in VB 5.0.  I would guess that the copytype.dll is only 16-bit and incompatible.  Regardless, I would like to know if VB 5.0 offers the equivalent functionality.

I appreciate your time and attention to this matter.
-David
dfhainesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mirkCommented:
Ok, the *easiest* way to do this in VB5, is to use
the LSET function, but this means you have to create
another User Defined Type to "copy" the strings into, like
this: Lset TypeWith1StringOf30Chars = TypeWith3StringsOf10Chars

Another way to do it would be to write the type to a file,
then read it back into your string.

Hope this is helpful - Mirk.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrmickCommented:
Mirk, LSet would only work in this manner when copying fixed length strings because strings variables not of a fixed length contain pointers to string data.  LSet can be used to copy a  structure (a number of bytes beginning at the offset of the first element) to another structure; however, VB won't copy data referred to by pointers.

dfhaines, you might find it easiest to write a VB function for each different structure (type) that packs its data into a string and perhaps a complementary UnPack function to re-populate the structure from the data packed into a string).

0
dfhainesAuthor Commented:
Mirk,
Thank you for your quick response.  The LSET function was sufficient and your advice helped automate a previously manually-intensive production task.  I do wonder, though, if the TypeToString function will be written for VB 5.0.  Perhaps you would agree that it would be a more efficient way to copy types to strings and would require less overhead.
Thanks again,
David
0
mirkCommented:
Yes, David, I agree... but thinking about it, another answer
could be to use a memory-copy function from the KERNEL...
My feelings are that this would be dangerous though.

Glad to have helped - Mirk


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.