Before I do a no no on a newsgroup, I need to ask a question: What is the
max number of lines of code you can/should post here before it gets too
long?
In my opinion if you are posting a question you should limit it the
the fewest lines of code that demonstrate the problem. Often times you
can pull out the extraneous actions and show only the ones that are
causing the problem. What you need to remember is that most people
here are not going to copy and paste your code into Visual Studio and
manually run through and try to find the problem. Most of us will
probably just read the code and offer what feedback we can. With that
said you want to keep it as simple as possible so when we browse
through the code we can mentally track what is going on. In my
opinion, I wouldn't recommend posting a question with code that has
more than 20 lines and a Cyclomatic Complexity (holy cow, was that a
college word I just used?) more than 6 or 7. Anything more and it'll
be hard to find what the problem is just by looking at the code.
However when it comes to posting a code sample in response to a
question the rules change. As far as I'm concerned if you are posting
code to help someone you should not skimp on what you provide. It
doesn't need to be a full fledged working sample tailored just for the
poster, I usually just post the pieces that are needed to get the
poster back on track, but I leave the "standard" bits and replace them
with comments on what needs to go there.
One other thing I learned long ago is to put your code in
distinguishing blocks to separate them from the rest of the code. The
model I follow (which was inspired by Herfried Wagner) is to put code
snippets in blocks like so:
/////////////////
Public Sub foo()
'// Do something cool
End Sub
/////////////////
Anyways, I'm not sure I answered your exact question, but its really
just a judgment call on your end. The worst thing that can happen is
that your post will be ignored because it will be too much work to
read through a huge code sample. That's probably the most important
thing to realize, the longer and more complex your post, the lesser
chance it will be answered.
Thanks,
Seth Rowe [MVP]