Last post Jun 23, 2011 03:57 PM by priyank80
Jun 21, 2011 05:18 AM|mezzanine74|LINK
I am working on my new server now. I have created very simple page which has a for loop on code behind. If i dont define "i" as integer before the loop, i got this error
Compiler Error Message: BC30451: Name 'i' is not declared.
But, i can use for loops without declaration of "i" before loop. Do you know what cause this?
For i = 1 To 10
Jun 21, 2011 05:30 AM|ignatandrei|LINK
As a best practice, you should have
Option Explicit On
and declare all variables.
Jun 23, 2011 03:57 PM|priyank80|LINK
This error raise due to "Option Explicit On". But This is good practise. You should use bellow code.
For i as Integer = 1 To 10
The compiler default is Option Explicit On if you do not specify Option Explicit in your code.
To set Option Explicit in the integrated development environment (IDE)