Very simple concept but....

C

Chris Kennedy

I always get a little confused with this. Quite often I end up writing code
with two lines.
Dim strTest as string
strTest = "test"

How do I write as one line and what is the theory behind instantiating
objects such as ado.net objects like this. Quite often I see very condensed
code, which accomplishes in one line what takes me several.
 
C

Craig Deelsnyder

I always get a little confused with this. Quite often I end up writing
code
with two lines.
Dim strTest as string
strTest = "test"

How do I write as one line and what is the theory behind instantiating
objects such as ado.net objects like this. Quite often I see very
condensed
code, which accomplishes in one line what takes me several.

It's really a matter of preference. Accomplishes the same thing; some
believe you should never initialize your variables in the same line (what
you're asking). It makes it easier to delineate defining a variable vs.
where it's initialized, especially when you have alot of variables, or if
the initialization is lengthy (line length gets a little long); often
times people will have a block of code after the list of declarations,
where they they initialize all the variables.

Me, I've done both. No difference either way....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top