Solved

TypeToString Function in VB5

Posted on 1998-04-02
4
200 Views
Last Modified: 2006-11-17
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
0
Comment
Question by:dfhaines
  • 2
4 Comments
 

Accepted Solution

by:
mirk earned 100 total points
Comment Utility
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
 
LVL 8

Expert Comment

by:mrmick
Comment Utility
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
 

Author Comment

by:dfhaines
Comment Utility
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
 

Expert Comment

by:mirk
Comment Utility
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

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now