Option Strict.

Michaelk

Well-known member
Joined
Jun 3, 2004
Messages
58
Location
Australia
Programming Experience
3-5
I've read in several places that Option Strict should be the first thing that any VB programmer does? I'm self taught, by books, fiddling and forums, and i've never used Option Strict.
Is anyone able to explain to me what it actualy does, and the advantages/disadvantages of using it?

Thanks.
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
in vb.net there are two compiler options you should turn ON
Option Explicit and Option Strict

Option Explicit On means that all variables that you use have to to be declared first, if you don't declare them you get a compile error. make sure it's ON

Option Strict On means that vb wont auto convert variable type ie DecAmount = intAmount instead you have to convert it intAmount = Convert.ToDecimal(intAmount) you're program will run faster if you convert the types yourself, option strict forces type conversion. for type conversion there is also the CType function as well.
 
Top Bottom