atribut defaultcollelem
Atribut [defaultcollelem] menandai properti sebagai fungsi pengakses untuk elemen koleksi default.
[property-attribute-list, defaultcollelem] return-type property-name(prop-param-list)
Parameter
-
property-attribute-list
-
Atribut lain yang berlaku untuk properti .
-
jenis pengembalian
-
Menentukan jenis pengembalian fungsi.
-
property-name
-
Nama properti.
-
prop-param-list
-
Daftar parameter nol atau lebih yang terkait dengan properti .
Keterangan
Atribut [defaultcollelem] digunakan untuk pengoptimalan kode Visual Basic®. Jika anggota antarmuka atau dispinterface ditandai sebagai fungsi pengakses, maka panggilan akan langsung masuk ke anggota tersebut.
Penggunaan [defaultcollelem] harus konsisten untuk properti. Misalnya, jika Anda menggunakan atribut pada properti Dapatkan , atribut tersebut juga harus ada di properti Let .
Representasi Typeflags
Kehadiran FUNCFLAG_FDEFAULTCOLLELEM atau VARFLAG_FDEFAULTCOLLELEM.
Contoh
//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
Lihat juga