BYTEINSIGHT
GAPVelocity AI Studio helps you move from outdated tech stacks to the latest desktop, web, and cloud platforms—smarter, faster, and with less risk.
Choose a platform to see migration options:
Our comprehensive approach to application modernization, from assessment to production deployment.
Transformation Services
Not Sure Where to Start?
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.
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.
Private Sub Form_Load() Dim myArray(0 To 2) As String myArray(0) = "First" myArray(1) = "Second" myArray(2) = "Third" Example myArray(0), myArray(1), myArray(2) MsgBox myArray(1) End Sub Public Sub Example(ParamArray params() As Variant) MsgBox "Second Parameter: " + params(1) params(1) = params(1) + "_modified" End Sub
Private Sub Form_Load() Dim myArray(2) As String myArray(0) = "First" myArray(1) = "Second" myArray(2) = "Third" Example(myArray(0), myArray(1), myArray(2)) MessageBox.Show(myArray(1), My.Application.Info.Title) End Sub 'UPGRADE_WARNING: (1003) ParamArray params was changed from ByRef to ByVal. Public Sub Example(ParamArray ByVal params() As Object) MessageBox.Show("Second Parameter: " & ReflectionHelper.GetPrimitiveValue(Of String)(params(1)), My.Application.Info.Title) params(1) = ReflectionHelper.GetPrimitiveValue(Of String)(params(1)) & "_modified" End Sub
private void Form_Load() { string[] myArray = new string[]{"", "", ""}; myArray[0] = "First"; myArray[1] = "Second"; myArray[2] = "Third"; Example(myArray[0], myArray[1], myArray[2]); MessageBox.Show(myArray[1], AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly())); } //UPGRADE_WARNING: (1003) ParamArray params was changed from ByRef to ByVal. public void Example(params object[] params_Renamed) { MessageBox.Show("Second Parameter: " + ReflectionHelper.GetPrimitiveValue<string>(params_Renamed[1]), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly())); params_Renamed[1] = ReflectionHelper.GetPrimitiveValue<string>(params_Renamed[1]) + "_modified"; }