Solved

TypeToString Function in VB5

Posted on 1998-04-02
4
201 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
ID: 1460265
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
ID: 1460266
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
ID: 1460267
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
ID: 1460268
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

825 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