Friday 15 June 2012

Model View Controller (MVC) implementation in Excel VBA

With this post I would like to illustrate the concept of Model View Controller (MVC) design pattern implemented in excel VBA with a simple and easy to understand example.

The model view controller design pattern has a benefit which provides separation of concern objectively while designing the solution. With this technique in hand, the data is modelled as an object and the form in which is represented is also modelled as object with relevant functions provided for the operations required, which is orchestrated by a controller class.


 

The attached example is a crude implementation of MVC a quick attempt of mine to achieve the same, though I do accept that this piece of code is far from perfection and has still room to improve upon.

Explanation:

The workbook has simple worksheet which on one side has form to display the data (left) and on (right) a table storing multiple values for the same. The workbook has two functionalities provided to get the relevant data based on the serial number provided and update functionality to update the corresponding the record.


 

Please check the workbook VBA code for MVC implementation details.

Download:

Download Solution
Download solution



Refrences:
Link: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

2 comments:

Unknown said...

Thanks for the example Amol! I've been searching for a simple approach to implementing MVC for an Access project that will be later moved to Web/.NET. Your post and code was VERY helpful!!

Unknown said...

Thanh Le
Thanks for your post !
It's greate.