Re: question(s) about declaring variables
- From: "Ken Halter" <Ken_Halter@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Jun 2005 08:01:45 -0700
"95isalive" <admin@xxxxxxxxxxxxx> wrote in message
news:eYKepayeFHA.3836@xxxxxxxxxxxxxxxxxxxxxxx
>
> Now that makes perfect sense.
> Also, mixing types in one Dim statement is something that never entered my
> mind.
fwiw, personal choice here.... I always use the "As String" format, never
the dollar sign and never declare more than one variable per line. When I
get sample code that has a bunch of variables declared on a single line or
use that ancient variable declaration syntax, if I plan on keeping that
sample, I break those lines up and add the correct variable types. One
declaration per line and "As Type" syntax improves readability far beyond
the few keystrokes you may save by taking shortcuts. Multiple declarations
on a single line makes it harder to spot a specific declaration when
browsing code.
Another thing I "clean up" in sample code that I want to keep is... single
line If/Then statements and I get rid of any multi-statement lines (like A =
5:B = 10). Those colons should've died with VB1 imo.... another thing that
drives me nuts is....
Dim A As String:A = "test"
That has the colon and the developer is trying to "fool" people into
thinking the variable is initialized while declaring it. Just another way to
introduce a bug and make things harder to read imo. Just plain nasty code
that'll change as soon as it hits my screen. Code like that doesn't even
save a keystroke but it sure makes it harder to read/maintain.
So... in the long run, it's all up to you... no changes in functionality....
but, expect your code to look completely different once it hits my PC and
I've decided to keep the "snip" <g>... one more thing I can live without
forever is people that align their "As Type" statements... like...
Dim A As String
Dim Bvar As Integer
....etc. That makes me do a search/replace of all occurances of 2 spaces in a
row. Too much work! <g> One space is all we need.
--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..
.
- Follow-Ups:
- Re: question(s) about declaring variables
- From: Michael C
- Re: question(s) about declaring variables
- From: MikeD
- Re: question(s) about declaring variables
- From: 95isalive
- Re: question(s) about declaring variables
- From: Ken Halter
- Re: question(s) about declaring variables
- References:
- question(s) about declaring variables
- From: Steve Easton
- Re: question(s) about declaring variables
- From: J French
- Re: question(s) about declaring variables
- From: Steve Easton
- Re: question(s) about declaring variables
- From: Bob Butler
- Re: question(s) about declaring variables
- From: 95isalive
- question(s) about declaring variables
- Prev by Date: compile dll with specific guid?
- Next by Date: Re: Run-time error '5' when hiding form
- Previous by thread: Re: question(s) about declaring variables
- Next by thread: Re: question(s) about declaring variables
- Index(es):
Relevant Pages
|