简体   繁体   中英

porting vb6 app to VS2008 vb.net - make compiler flag unitialized form's private variable as error

I can make the compiler give me an error (Use of variable prior to assignment) with:

private sub Test()
   Dim ord As Order
   Dim ord2 As Order
   ord2 = ord
end sub

but not with:

Friend Class frmReceiving
...

Private mobjOrder As Order 

...

private sub Testing()
   Dim ord2 As Order
   ord2 = mobjOrder 
end sub

How can I make it flag as error?

thanks.

Yes.

Use the /warnaserror compiler option.

http://msdn.microsoft.com/en-us/library/2xz9dxe5.aspx

Your second example is not an error. mobjOrder will be initialized to Nothing . You then assign Nothing to ord2 . That's a perfectly legitimate thing to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM