[VB] [reflection] Using typelib information to enumerate object attributes and callbyname reflection to call Functions

Source: Internet
Author: User

Use typelib information to enumerate object attributes and call functions using callbyname reflection

 'Reference typelib Information </P> <p> sub listcontrols () <br/> cells (1, 1) = "control" <br/> cells (1, 2) = "properties, methods, events" <br/> cells (1, 3) = "value" <br/> [A1: C1]. interior. colorindex = 3 <br/> on error resume next <br/> dim CTL as object, N as long <br/> n = 1 <br/> for each CTL in userform1.controls <br/> dim iinf as interfaceinfo <br/> set iinf = interfaceinfofromobject (CTL) <br/> if not (iinf is nothing) Then <br/> dim mem as memberinfo <br/> for each MEM in iinf. members <br/> If mem. invokekind then <br/> N = n + 1 <br/> cells (n, 1) = CTL. name <br/> cells (n, 2) = mem. name <br/> cells (n, 3) = callbyname (CTL, mem. name, vbget) <br/> end if <br/> next <br/> [A1: c65536]. columns. autofit <br/> end sub <br/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.