why does this code not produce an error?

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hi,

why does this code not produce an error that variable i is not declared?
Why is dim i as integer not necessary?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
For i = 1 To 5
Response.Write(i)
Next
End Sub

webconfig: <compilation debug="false" strict="false" explicit="true">

Thanks
Luc
 
Ben said:
Hi,

why does this code not produce an error that variable i is not declared?
Why is dim i as integer not necessary?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
For i = 1 To 5
Response.Write(i)
Next
End Sub

webconfig: <compilation debug="false" strict="false" explicit="true">

Thanks
Luc

Add Option Infer Off a the top of your vb code for the page. I believe
the compiler can infer that "i" is an integer from the context.
 
thanks
Family Tree Mike said:
Add Option Infer Off a the top of your vb code for the page. I believe
the compiler can infer that "i" is an integer from the context.
 
Back
Top