![]() |
Модераторы: Akina |
![]() ![]() ![]() |
|
cardinal |
|
||||||||||||||||||||||||||||
![]() Инженер ![]() ![]() ![]() ![]() Профиль Группа: Экс. модератор Сообщений: 6003 Регистрация: 26.3.2002 Где: Германия Репутация: 19 Всего: 99 |
Вот что написано в MSDN:
Creating Your Own Data Types You can combine variables of several different types to create user-defined types (known as structs in the C programming language). User-defined types are useful when you want to create a single variable that records several related pieces of information. You create a user-defined type with the Type statement, which must be placed in the Declarations section of a module. User-defined types can be declared as Private or Public with the appropriate keyword. For example:
-or-
For example, you could create a user-defined type that records information about a computer system:
Declaring Variables of a User-Defined Type You can declare local, private module-level, or public module-level variables of the same user-defined type:
The following table illustrates where, and with what scope, you can declare user-defined types and their variables. Procedure/Module You can create a user-defined type as... Variables of a user-defined type can be declared... Procedures Not applicable Local only Standard modules Private or public Private or public Form modules Private only Private only Class modules Private or public Private or public Note If declared using the Dim keyword, user-defined types in Standard or Class modules will default to Public. If you intend a user-defined type to be private, make sure you declare it using the Private keyword. Assigning and Retrieving Values Assigning and retrieving values from the elements of this variable is similar to setting and getting properties:
You can also assign one variable to another if they are both of the same user-defined type. This assigns all the elements of one variable to the same elements in the other variable.
User-Defined Types that Contain Arrays A user-defined type can contain an ordinary (fixed-size) array. For example:
It can also contain a dynamic array.
You can access the values in an array within a user-defined type in the same way that you access the property of an object.
You can also declare an array of user-defined types:
Follow the same rules to access the components of this data structure.
Passing User-Defined Types to Procedures You can pass procedure arguments using a user-defined type.
Note If you want to pass a user-defined type in a form module, the procedure must be private. You can return user-defined types from functions, and you can pass a user-defined type variable to a procedure as one of the arguments. User-defined types are always passed by reference, so the procedure can modify the argument and return it to the calling procedure, as illustrated in the previous example. Note Because user-defined types are always passed by reference, all of the data contained in the user-defined type will be passed to and returned from the procedure. For user-defined types that contain large arrays, this could result in poor performance, especially in client/server applications where a procedure may be running on a remote machine. In such a situation, it is better to extract and pass only the necessary data from the user-defined type. For More Information To read more about passing by reference, see "Passing Arguments to Procedures" in "Programming Fundamentals." User-Defined Types that Contain Objects User-defined types can also contain objects.
Tip Because the Variant data type can store many different types of data, a Variant array can be used in many situations where you might expect to use a user-defined type. A Variant array is actually more flexible than a user-defined type, because you can change the type of data you store in each element at any time, and you can make the array dynamic so that you can change its size as necessary. However, a Variant array always uses more memory than an equivalent user-defined type. Nesting Data Structures Nesting data structures can get as complex as you like. In fact, user-defined types can contain other user-defined types, as shown in the following example. To make your code more readable and easier to debug, try to keep all the code that defines user-defined data types in one module.
Если проблемы с англ., то надо чтобы кто-то это немного перевел. ![]() -------------------- Немецкая оппозиция потребовала упростить натурализацию иммигрантов В моем блоге: Разные истории из жизни в Германии "Познание бесконечности требует бесконечного времени, а потому работай не работай - все едино". А. и Б. Стругацкие |
||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
![]() ![]() ![]() |
Правила форума "VB6" | |
|
Запрещается! 1. Публиковать ссылки на вскрытые компоненты 2. Обсуждать взлом компонентов и делиться вскрытыми компонентами
Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Akina. |
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
0 Пользователей: | |
« Предыдущая тема | VB6 | Следующая тема » |
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |