HighTechTalks DotNet Forums  

Issue of Type.InvokeMember

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss Issue of Type.InvokeMember in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
peter
 
Posts: n/a

Default Issue of Type.InvokeMember - 01-12-2004 , 03:32 AM






Using Type.InvokeMember to call a method of a class,Which
method has byref parameter,It seems that there is
no way to return the changed value of that byref
parameter by the method of the class.
Who can save me?
Thanks a lot!


Reply With Quote
  #2  
Old   
Peter van der Goes
 
Posts: n/a

Default Re: Issue of Type.InvokeMember - 01-12-2004 , 07:05 AM







"peter" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Using Type.InvokeMember to call a method of a class,Which
method has byref parameter,It seems that there is
no way to return the changed value of that byref
parameter by the method of the class.
Who can save me?
Thanks a lot!

It may be that I don't full understand you problem, but if you pass a
parameter by reference, that gives the method in question access to the
original data, thus the capability to alter the original data without having
to return anything. Why would you need/want to return the changed value?

--
Peter [MVP Academic]




Reply With Quote
  #3  
Old   
peter
 
Posts: n/a

Default Re: Issue of Type.InvokeMember - 01-12-2004 , 08:54 AM



Thanks for your response.

For example,
an COM class named myclass ,it has a method named
mymethod an its VB code is like this:

Public Class myClass
Public Function mymethod(ByVal a As Integer, ByVal b
As Integer, ByRef c As Integer) As Integer
c = a - b
Return a + b
End Function
End Class

The class has been compiled into a COM dll named
myTest.dll,then use it in VB.NET,like this:

Dim Aobj() As Object = {15, 6, 3}
MsgBox(Aobj(2))
Dim obj As New myTest.myclass()
Dim T As Type = Type.GetTypeFromProgID("myTest.myclass")
dim d as object
d= T.InvokeMember("mymethod",
Reflection.BindingFlags.Public Or
Reflection.BindingFlags.InvokeMethod Or
Reflection.BindingFlags.Instance, Nothing, obj, Aobj)
MsgBox(Aobj(2))
MsgBox(d)

IN the code,the desired value of Aobj(2) is 9,but it
remains 3.
what shall I do ?
An early reply will be appreciated.


Quote:
-----Original Message-----

"peter" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message
news:01f701c3d8e6$a95e8ed0$a001280a (AT) phx (DOT) gbl...
Using Type.InvokeMember to call a method of a
class,Which
method has byref parameter,It seems that there is
no way to return the changed value of that byref
parameter by the method of the class.
Who can save me?
Thanks a lot!

It may be that I don't full understand you problem, but
if you pass a
parameter by reference, that gives the method in
question access to the
original data, thus the capability to alter the original
data without having
to return anything. Why would you need/want to return
the changed value?

--
Peter [MVP Academic]


.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.