But cant you use a type for even going through the items in a
collection?
Like say you are going through the forms collection.. Cant you just
declare the var as a form?
Or say an adodb.fields collection.. Declare it as an adodb.field..
Right? Or am I off here.
daniel
--------------------------
Daniel O'Dorisio
daniel@o...
www.odorisio-networks.com
--------------------------
-----Original Message-----
From: Rick Dunmire [mailto:dunnie@p...]
Sent: Thursday, October 25, 2001 6:52 PM
To: professional vb
Subject: [pro_vb] Re: Using the Dim statement
Thanks everyone
I kinda fell into an important piece of information here.
I put the Option Explicit statement in my program and man the errors i
got. I tried to quickly correct some of them and decided to stop till I
had more time to correct them. Its just a small app with a listview, a
sstab, a data connection and a adodb connection and it looks like I need
10 ft of dim statements. I don't know weather to curse or sing praise.
Thanks again
----- Original Message -----
From: "Ian Ashton" <ian@c...>
To: "professional vb" <pro_vb@p...>
Sent: Thursday, October 25, 2001 3:02 PM
Subject: [pro_vb] Re: Using the Dim statement
> Cardyin,
>
> Your point (3):
>
> If one is sloppy and does not specifically Dim a variable as a type
(Shades
> of ghastly VBScript), it will, of course,
> be a variant which means you can store anything in it.
>
> Personally, on the occasions that it is absolutely necessary (and not
> just being lazy) that a variable be a variant, I always explicitly
> declare it as a variant so that it is apparent to
anyone
> reading the code (including myself) that
> it was a deliberate and not an accidental requirement.
>
> e.g.
>
> dim varItem as variant
>
> (for use in iterating through the Items in a collection)
>
>
> Ian Ashton
>
> -----Original Message-----
> From: Kim, Cardyin [mailto:CKim@s...]
> Sent: Thursday, October 25, 2001 6:22 PM
> To: professional vb
> Subject: [pro_vb] Re: Using the Dim statement
>
> Please ignore the last post...I accidentally sent it before
> I was done :)
>
> I am one of those people who religiously use Option Explicit. Here is
> the reasons why:
>
> 1) Option Explicit forces you do declare your variables.
>
> This will eliminate any problems in your program that
> are caused due to typos. Here is an example:
>
> You are using a variable named strTempVariable in your program. In
> the middle of the program somewhere you accidentally type
> strTmpVariable = 10 or something else. Without option explicit, that
> line will simply create another variable and give it the value of 10.
> When it may be critical at that point that the
> variable be set to 10.
>
> With option explicit used, you will simply get an error
> on that line when you try to run/compile it, making it
> easy to debug typos.
>
> 2) Option Explicit forces you to declare your varibles.
>
> For simple variables, your program will know at
> COMPILE time, what size and type of memory space to
> allocate for your variable. This means that your
> executable will be smaller, use less memory while running, and execute
> faster. (Basically: Early Binding vs. Late Binding)
>
> For more complex objects, such as ADODB.Connection,
> you the above still applies, but you get the added
> bonus of exposing the properties and methods in
> intellesense (that little mini menu) during design time.
>
> 3) Option Explicit forces you to declare your variables.
>
> This means that if you declare a variable as integer,
> you can't store a string in it. This reduces the
> amount of coding errors that may occur when coding.
>
> Hope this helps,
>
> Cardyin
>
> ---------------------------------------
> Cardyin Kim
> Client/Server & Web Development Analyst
> Information Services
> San Antonio Community Hospital
> ckim@s... (xxx)xxx-xxxx
> ---------------------------------------
>
>