General discussion

Locked

Avoid program bugs with Optional Explicit

By MaryWeilage Editor ·
This week's Visual Basic newsletter describes how you can avoid program bugs by utilizing the Optional Explicit statement.

Have you run into any issues with explicit declarations? If so, do you find the Option Explicit statement a good workaround for the problem outlined in this tip?

If you aren't subscribed to our free Visual Basic newsletter, click the following link to automatically sign up:
http://nl.com.com/MiniFormHandler?brand=builder&subs_channel=bldr_front_door&list_id=e065&tag=fb

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Explicit

by ccalvin In reply to Avoid program bugs with O ...

I have been programming in BASIC since 1973. Implicit definition makes it easy for students to create simple programs which was the original intent of BASIC. But for any serious programming, OPTION EXPLICIT is a necessity. Using Option Explicit will save time and headaches.

Collapse -

This should not be an option

by rayt In reply to Avoid program bugs with O ...

We make use of this mandatory in all of our code.

Collapse -

Saved My Bacon

by kwf777 In reply to Avoid program bugs with O ...

I only use VBScript on ASP pages for reports out of SQL Server and it has saved me headaches more times than I can remember. I am not the greatest typist and fat finger many thingsi n code. I think it should be mandatory in any VB coding in an enterprise.

Collapse -

Problem with Option Explicit

by Rexxrally In reply to Avoid program bugs with O ...

One problem I encountered with Option Explicit is that if you switch it ON after creating project modules and/or forms (M/F), VB does not add Option Explicit to the already created M/F. You have to run around and add Option Explicit to the top of each M/F. Not knowing this caught me out for a while.

Collapse -

Efficiency issues

by ferdfrog In reply to Problem with Option Expli ...

I always use Option Explicit while I'm developing and then remove it right before compiling or releasing an asp page.

I would assume that option explicit requires the application to parse the code and that would seem to me to be a waste of resources AFTER you are finished developing.

Does VB strip the option explicit from the application during compilation? Or should I remove it manually before I compile?

Collapse -

No effect

by dogknees In reply to Efficiency issues

Leaving it in has no effect. It only has an effect when you modify the code and cause or force a recompilation. It modifies the behaviour of the compiler to disallow implicit declaration.

Regards

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums