WARNING #1003

    ParamArray 1% was changed from ByRef to ByVal.

    Description

    In Visual Basic, the Param Array keyword could be used to specify an arbitrary number of parameters for a declaration, sub, or function. ParamArrays were always passed by reference (ByRef). In Visual Basic .NET, ParamArrays are always passed by value; the Param Array keyword must be preceded by the ByVal keyword.

    When a parameter is passed by value, a copy of the variable is passed; when passed by reference, a pointer to the variable is passed. When passing by value, it is possible that the value of the variable may have changed and that the copy is out of date.

    Recommendations

    Review the code to make sure that the variables being passed as parameters are not being changed between the time that they are set and the time that they are used in a procedure. If necessary, modify your code so that the procedure executes before the variables are modified.

    Sample VB6

    PublicFunction AppendParams(ByValParamArray strNames()) AsString
          Dim intIndex AsInteger
          Dim Result AsString
          Result = ""
          For intIndex = 0 To UBound(strNames)
              If strNames(intIndex) <> ""Then
                   Result = Result & strNames(intIndex)
              EndIf
          Next
          AppendParams = Result
    EndFunction

    Target VB.NET

    'UPGRADE_WARNING: (1003) ParamArray strNames was changed from ByRef to ByVal.
    PublicFunction AppendParams(ByValParamArray strNames() AsString) AsString
          Dim Result As StringBuilder = New StringBuilder()
          For intIndex AsInteger = 0 To strNames.GetUpperBound(0)
                 If strNames(intIndex) <> ""Then
                       Result.Append(strNames(intIndex))
                  EndIf
           Next
           Return Result.ToString()
    EndFunction

    Target C# 

    //UPGRADE_WARNING: (1003) ParamArray strNames was changed from ByRef to ByVal.
    publicstring AppendParams(params string[] strNames)
    {
          StringBuilder Result = new StringBuilder();
          for (int intIndex = 0; intIndex <= ((int) ((object[]) strNames).GetUpperBound(0)); intIndex++)
          {
               if (strNames[intIndex] != "")
               {
                   Result.Append(strNames[intIndex]);
               }
          }
          return Result.ToString();
    }


    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration