why does this code not produce an error?

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
 
F

Family Tree Mike

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.
 
B

Ben

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top