What is the meaning of the UDT length?

xiaoxiao2021-03-05  49

There are two lengths of UDT, one is the length of writing files, one is the length of the actual memory. The two must be different!

For fixed length UDT, it is generally the length of its write file. If all UDTs are fixed, you can use Len to be drawn directly. If you contain a long content, such as your xx () AS XXX dynamic array, or grow String, it is difficult, it may take one by one.

Because of the dynamic array or growing string in the UDT, the LEN returns only 4 bytes, equivalent to a 32-bit pointer.

For example: Public Type A XX AS Integer XXX As Longend Type

Public Type B xx () AS Integer 'Dynamic Dimension XXX (100) AS AEND TYPE

Public Type C xx as a xxx as behind

Public CCC AS Credim Ccc.xxx.xx (10) Debug.print Len (CCC) Will get Len (CCC) = 616 regardless of RedIm CCC.xxx.xx (10) or RedIm CCC.xxx.xx (1000) result

Look at the length: Type A length: Integer long = 2 4 = 6 Byte type B length: integer () a (100) = 4 101 * 6 = 610 type C length: a b = 6 610 = 616

And the actual length: When redim ccc.xxx.xx (10), the length of CCC is = 616-4 2 * 11 = 634

The above method is really troublesome. And although it can calculate the length of the write file, whether VB can be written in this length normally, or maybe! A further introduction is for reference only: For the fixed length UDT, the VB can be continuously stored in memory regardless of the memory, so VB can use Len to draw the length, and can be directly replicated with CPYMEMORY;

For growing content, VB is continuously stored in content, only one pointer to the gendensive content storage address, at this time, VB will not write files according to the calculated actual length, and can only be written according to the result of LEN. Therefore, it may be only a memory pointer, and it is definitely an error. At the same time, CPYMEMORY is also very dangerous. If you press the actual length COPY, you will not know the predicts on the back, if you press the LEN length COPY, it is possible to generate two different variables to point to the same address. In summary, for the growth of UDT, the length of its length is achieved, so it has achieved the meaning of its length, and there is almost no practical utilization! Therefore, VB is based on this, and does not provide a method of calculating its length.

转载请注明原文地址:https://www.9cbs.com/read-36728.html

New Post(0)