paramarray

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone

In VB6,paramarray parameter is passed using byref,but in VB.NET,using byval.How can I get back the changed value of the paramarray parameter

My work case in vb.net like this
----------------------------------------------------
Function mytestmethod(paramarray byval arg() as object
arg(0)=1
arg(1)="abc
End Functio

Sub mycalling(
dim a as integer=6
dim b as string="xyz
mytestmethod (a,b
msgbox (a
msgbox (b
End Su
----------------------------------------------------
the expected value of a,b is 12,"abc";but it remains 66 or "xyz"

Who can help me

Best regard

pete
 
Try using an ArrayList instead. You can pass it byref or byval as you wish

Mariano.
 
Hi Peter,

I think exactly as you tell it your function (what is a sub)

The sample shows you that the byval is a reference of the object.

Sub mytestmethod(byval arg() as object)
arg(0)=12
arg(1)="abc"
End Function
Sub mycalling()
Dim obj(2) As Object
obj(0) = 66
obj(1) = "xyz"
mytestmethod(obj)
MsgBox(obj(0))
MsgBox(obj(1))
end sub

I hope this helps?

Cor
 

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

Similar Threads


Back
Top