views:

180

answers:

4

I never really know how to name VBA modules. Should I:

  1. Use a prefix, like basName or modName.
  2. Not use a prefix, like Module. (But avoid restricted words)
  3. Something else
+3  A: 

Do not prefix! Name the module appropriately for what it does.

ChaosPandion
Yeah, I feel pretty ridiculous using a prefix because I'm trying to get rid of hungarian in my VBA code. Just not sure best way to create unique names. Most of my modules are single words.
EdOxH
Any thought on singular vs. plural names?
EdOxH
Be careful that you do not also have a procedure of the same name.
Remou
Don't just bark out orders! Provide the rationale behind your opinion.
raven
@raven - I would if it were something more than opinion. This opinion however has been common among developers I've met. Not universal but common.
ChaosPandion
+2  A: 

Granted, this is taking the way back machine, but when I did extensive VBA development, I always named my modules with a prefix of something like "bas" because the names of Class modules and Global modules in combination had to be unique (i.e. you couldn't have a Global module named Foo and Class module named Foo). I believe the same was true of VB6 but that was many moons ago.

Thomas
I think this also helps to ensure that modules do not contain procedures of the same name.
Remou
A: 

A prefix can be useful just for the sake of making related modules appear next to each other in the project window. I use prefixes like "numeric" or "test" all the time in lieu of some other way to group them. But you probably don't need something like "mod"...

jtolle
+1  A: 

I prefix standard modules with M, class modules with C, and userforms with U. In the VBE, I turn off the folder view in the project explorer to show all of the modules. The prefixes keep them nicely sorted.

Dick Kusleika