atribut defaultcollelem

Atribut [defaultcollelem] menandai properti sebagai fungsi aksesor untuk elemen koleksi default.

[property-attribute-list, defaultcollelem] return-type property-name(prop-param-list)

Parameter-parameternya

property-attribute-list

Atribut lain yang berlaku untuk properti .

jenis pengembalian

Menentukan jenis pengembalian fungsi.

nama properti

Nama properti.

prop-param-list

Daftar parameter nol atau lebih yang terkait dengan properti .

Komentar

Atribut [defaultcollelem] digunakan untuk pengoptimalan kode Visual Basic ®. Jika anggota antarmuka atau dispinterface ditandai sebagai fungsi aksesor, maka panggilan akan langsung masuk ke anggota tersebut.

Penggunaan [defaultcollelem] harus konsisten untuk properti. Misalnya, jika Anda menggunakan atribut pada properti Get , atribut tersebut juga harus ada di properti Let .

Representasi Typeflags

Kehadiran FUNCFLAG_FDEFAULTCOLLELEM atau VARFLAG_FDEFAULTCOLLELEM.

Examples

//A form has a button on it named Button1. 
//To enable use of the property syntax and efficient use of the !
//syntax, the form describes itself in type info this way.
[
    dual,
    uuid(12345678-1234-1234-1234-123456789ABC),
    helpstring("This is IForm"),
    restricted
]
interface IForm1: IForm
{
    [propget, defaultcollelem] HRESULT Button1(
        [out, retval] Button *Value);
}

//User code may access the button using property syntax or ! syntax.

Sub Test()
Dim f as Form1
Dim b1 As Button
Dim b2 As Button

Set f = Form1

Set b1 = f.Button1        ' Property syntax
Set b = f!Button1        ' ! syntax
End Sub

Baca juga

Sintaks File ODL

Contoh File ODL

Membuat Pustaka Jenis Dengan MIDL