excel - Using a class object to make different shapes -


my excel sheet creates map various layers, showing network made of lines, squares, dots, , triangles. have functions each creation take arguments such as

celllocation range  '(takes given cell location) shapetype string    '(oval, triangle, rectangle) color                  '(red, black, whatever) sizefactor double   '(factors shape size function of cell's width) 

i learning classes now, wondering if classes useful in case, , how use them simplify code, rather having functions 6 different arguments , such.

originally had functions this:

function createwell(cellrng range, wellname string) 'creates square of particular color, size, etc in cellrng , names wellname  function createcompressor(cellrng range, compname string) 'creates oval of particular color, size , etc. similar other func. 

then, because had 5 of these variations color, size, shape, etc. tried making overall function:

 function createshape(cellrng range, shpname string, _             shpcolor string, shpsize double, shptype string) 

but seems messy (too many arguments). how can employing classes clean type of code?

you right. need use object oriented concepts of language. vba not complete object oriented language has nice features. cant write example because there more 1 way this. i wanted comment , not write answer low rating preventing me. read object oriented concepts , working classes, crating instances classes overloading function different stamps , enums. if want more modern language (like visual basic.net example) read inheritance , polimorphizem - important concepts implement tasks mentioned.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -