views:

503

answers:

2

I am upgrading a VB6 to VB.NET project using the upgrade wizard. I know this is going to give me a lot of grief, but I am trying to make the old application useable. I'd rewrite it if I had time but am currently finishing up a summer internship and would like to get something working.

One thing the wizard is doing that I can find no justification for is renaming of random variables. For example:

Structure ctrObj
 Dim Name As String
 Dim Index As Integer
 Dim Top As Integer
 'UPGRADE_NOTE: Left was upgraded to Left_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
 Dim Left_Renamed As Integer
 Dim Height As Integer
 Dim width As Integer
 Dim ScaleHeight As Integer
 Dim ScaleWidth As Integer
End Structure

For the life of me I don't understand why this is changing left. It isn't a reserved name as far as I can tell, there is no other variable named left that I can find in scope, and renaming it does not create a compiler error.

'UPGRADE_NOTE: Left was upgraded to Left_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
 Dim Left_Renamed As Integer

changed to

Dim Left As Integer

does not give a compiler error.

It does this to seemingly random variables throughout my project. Anyone have ideas as to why it doesn't like some of my variable names?

+2  A: 

My best guess is that it's renaming Left to avoid confusion with the VB Function Left. This is a method on a module in a namespace which is default imported into every VB.Net project. As such it is globally available.

For example: This compiles just fine

Dim x = Left("here", 1)

It is probably worried that there could be an ambiguity error if the function was used without arguments. For example

Public Structure S1
  Public Left As Integer
  Public Sub Method1()
    Dim x = Left
  End Sub
End Structure

However this can't happen though for a couple of reasons. Primarily VB's name binding rules will prefer the member variable Left over the Module Function Left.

So, not entirely sure why but it's probably an over caution to avoid potential ambiguity.

JaredPar
Makes sense, though that's very annoying. It is also doing this with a variable called logger-is there some default imported method called Logger?
+1  A: 

Left is a string function in Visual Basic. It takes the specified number of characters from the left side of a string and returns a new string containing those characters.

Robert Harvey