Anisha Hosting
£10.00 per month
>> Discover more ...
eCommerce Hosting
£14.00 per month
>> Discover more ...
SQL Server Hosting
£22.00 per month
>> Discover more ...
Anisha Tutorials
Your domain available:

Articles

Windows 2003 - IIS6 Hosting Provider

Dot Net Hosting


MySQL

php


free webmail

FREE WebMail as standard
with all hosting account

 


dotnet hosting visual studio.net

Hosting with a difference ...

 

Tutorial - ASP - Using ASP.NET Option Strict

When used the Option Strict statement must appear before any other code.

Visual Basic .NET generally allows implicit conversions of any data type to any other data type. Data loss can occur when the value of one data type is converted to a data type with less precision or smaller capacity!

However run-time error message will occur if data will be lost in such a conversion.

Option Strict ensures compile-time notification of these types of conversions so they may be avoided. Additionally to the conditions described above, Option Strict generates an error for:

  • Undeclared variable since it is implied that Option Strict also means Option Explicit.
  • Late-binding.

Option Strict On ' Force explicit variable declaration.
Dim MyVar As Integer ' Declare variables.
Dim Obj As Object
MyVar = 1000 ' Declared variable does not generate error.
MyVar = 1234567890.987654321 '
'Attempting to convert to an Integer will generate an error.
MyInt = 10 ' Undeclared variable generates error in Option Strict mode.
Call Obj.Method1() ' Late-bound call generates an error

 

 

 

All Rights Reserved Anisha.co.uk