When to use a Class in VBA?

后端 未结 12 1178
情歌与酒
情歌与酒 2020-12-02 07:04

When is it appropriate to use a class in Visual Basic for Applications (VBA)?

I\'m assuming the accelerated development and reduction of introducing bugs is a common

12条回答
  •  天命终不由人
    2020-12-02 07:45

    You can define a sql wrapper class in access that is more convenient than the recordsets and querydefs. For example if you want to update a table based on a criteria in another related table, you cannot use joins. You could built a vba recorset and querydef to do that however i find it easier with a class. Also, your application can have some concept that need more that 2 tables, it might be better imo to use classes for that. E.g. You application track incidents. Incident have several attributes that will hold in several tables {users and their contacts or profiles, incident description; status tracking; Checklists to help the support officer to reply tonthe incident; Reply ...} . To keep track of all the queries and relationships involved, oop can be helpful. It is a relief to be able to do Incident.Update(xxx) instead of all the coding ...

提交回复
热议问题