How to pass strings By Ref from VB.NET to VB6 OCX?
I need to pass 2 strings from VB.NET to an OCX written for VB6. VS2008 put a wrapper on the OCX, but while the routine is called, the string parameters are not correctly received.
I do not know why but I am guessing that it is because, as I understand it, in VB6 parameters are passed By Ref as a default while in VB.NET, parameters are passed Bv Val as a default.
When I imported the OCX into VS 2008, it seems to have automatically defaulted the string parameters for the routine I need to By Val because the ocx export info did not specify anything.
Is there anyway to override VS 2008 so that I can pass the strings correctly to the OCX?
Is there something else instead that开发者_JS百科 I could do?
I have 30000 files encrypted with FastEncrypt by JSoft, which seems to have gone out of business, and I need to incorporate FastEncrypt into a VB.NET program in order to use them.
Any help would be greatly appreciated.
Thank you.
Microsoft changed the default behaviour of parameters from VB6 to VB.NET. In VB6 the default (if not specified) is ByRef and in .NET the default (if not specified) is ByVal.
You can of course override the default behaviour and specify either ByRef or ByVal in either language so if you are porting some code from VB6 to .NET if it appears as
Public Function Foo(blnOption as Boolean) as Boolean
The equivalent in VB.NET is
Public Function Foo(ByRef blnOption as Boolean) as Boolean
. As good practise I always explicitly specify it so that anyone reading the code knows and it makes migrating code easier because you don't have to remember to set it.
精彩评论