|
-
Nov 10th, 2000, 10:31 AM
#1
Thread Starter
Frenzied Member
HI,
I was wondering. I know Option Explicit
is something you are suppose to use but
I never use it! So Why should I use it
and how would it help me? Thanks!
-
Nov 10th, 2000, 10:39 AM
#2
Lively Member
There is nothing wrong if you don't use it in your program, but it is pretty useful when you write a big program because if you use this option, you will have to declare all of variables before using it. Therefore, it's easy when you want to dedug the program.
-
Nov 10th, 2000, 10:39 AM
#3
Frenzied Member
You really are supposed to use it, yeah.
It's a security for typos... because when you type
Code:
Dim intT%
Do While int < 5 'note the int instead of intT
'do something
Loop
It'll end in a endless loop
When you used Option Explicit you'll got an error...
It basicly checks if you declared any variable, if not you'll get warned...
It's also usefull to prevent from 'forgetting' do declare variables (which makes them variants, and they're memory consuming)
... so it's a good thing to use it.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 10th, 2000, 11:17 AM
#4
Hyperactive Member
Hey Jop, obviously your 'Do something wil include incrementing intT ;-)
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Nov 10th, 2000, 11:28 AM
#5
Frenzied Member
Good thinking T.D.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 10th, 2000, 11:47 AM
#6
Thread Starter
Frenzied Member
Thanks!
You wouldnt believe what happened in
my project when I put 'Option Explicit'
in all the modules and forms!
It took almost 10 minutes to fix all of
the errors! Thanks alot!
Evan
-
Nov 10th, 2000, 11:52 AM
#7
Frenzied Member
You can also let VB automaticly add it to any form/module/etc.
click Tools > Options > and check Require variable Declaration
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 10th, 2000, 12:15 PM
#8
Thread Starter
Frenzied Member
-
Nov 10th, 2000, 01:06 PM
#9
New Member
Option Explicit
As i understand that option explicit is basically a variable case spell checker.
for example:
Option Explicit
Dim MyName as String
__________________________
Public Sub PrintName_Click()
'If you type
myname = "Trinity"
'it will change it to....
MyName = "Trinity"
-
Nov 10th, 2000, 01:23 PM
#10
Frenzied Member
Nope, not really, that's already done in VB automaticly.
it just checks if the variable is declared somewhere.
Like
Dim intT%
and int < doesn't exists so gives an error, try for yourself.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 10th, 2000, 01:29 PM
#11
Fanatic Member
Also
Straight out of MSDN.
If you don't use the Option Explicit statement, all undeclared variables are of Variant type unless the default type is otherwise specified with a Deftype statement.
-
Nov 10th, 2000, 02:10 PM
#12
Frenzied Member
yeah, that's what I said (gamma) hehe sorry dutch joke 
sorry I'm in a childish mood...
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|