In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to customize type parameters in VB". In daily operation, I believe many people have doubts about how to customize type parameters in VB. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to customize type parameters in VB". Next, please follow the editor to study!
Transfer of VB custom type parameters
User-defined type is an important data type in VB. It provides programmers with great flexibility and allows developers to construct their own data structures according to their needs. It is equivalent to the structural type (structure) in Candlestick +. In VB, programmers are allowed to pass custom data type parameters to the dynamic library by address, and the DLL process can also return the modified parameters to the VB program. However, passing VB custom type parameters by passing values is still not supported in VB.
When passing VB custom type parameters, you must ensure that the members of the data types in the VB correspond to the structure members in the dynamic library and occupy exactly the same space. The one-to-one correspondence here not only means that all structure members in the VB must have corresponding elements in the structure of the dynamic library, but also that the order in which they are defined in the data structure must be strictly consistent, which is determined by the "data structure member alignment" used in VB. In VB, data structures use double word alignment (4-byte alignment), so when users generate their own dynamic link libraries for VB calls, the compilation option "structure member alignment" must also be set to 4 bytes (as described earlier).
The so-called structure member alignment refers to the arrangement of its members within a data structure. For example, in VB, the alignment is 4 bytes, which is like dividing many small 4-byte units within a data structure, if the size of two or more adjacent data members can be placed in one unit, then put together; otherwise, unused empty bytes may appear in these small units. Let's take a look at the following data types:
Type TestType m1 as Integer m2 as Byte m3 as Long End Type
The size of its three members adds up to 2-1-4-7. However, because the total byte length of M1 and m2 is 3, less than 4, they are stored in a unit; but the remaining byte of the unit is not enough to hold a long member m3, so m3 is placed in the next unit, and there is an unused empty byte between them; therefore, the actual length of the whole structure is 8 bytes. By the same token, if you swap the positions of m3 and m2, the size it occupies becomes 9 bytes. It can be seen that the order in which members are declared in the structure is also very important.
In addition, the pointer of a function can be passed to the dynamic library in VB, and the method is not complicated. However, the author strongly recommends that * do not do this, because as a result, VB applications lose almost all of the security they should have. If you really need to pass function pointers, you should write a program called C _ pointer + to do the job.
At this point, the study on "how to customize type parameters in VB" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.