none
Equivalent data type in C# for [in, out] type in VB6 RRS feed

  • Question

  • Hi,

    I have a requirement to move certain part of a project written in VB6 to C#.

    In VB6 there is one kind of parameters to method which is [in, out]. 

    This method I want to re-write in C# but the caller will still remain in VB6.

    Can anyone suggest what is the best way to do this!?

    Thank you,

    Regards,

    Sasikala

    Wednesday, May 23, 2018 10:26 AM

Answers

  • Hi Sasi,

    You can use ref keyword. Just point to the memory location where the variable is holding value and access that location using C#. Please look into the below article for more information.

    ref (C# Reference)

    Ref and Out (The Inside Story)


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered"Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


    Wednesday, May 23, 2018 10:54 AM
    Moderator

All replies

  • Hi Sasi,

    You can use ref keyword. Just point to the memory location where the variable is holding value and access that location using C#. Please look into the below article for more information.

    ref (C# Reference)

    Ref and Out (The Inside Story)


    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered"Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


    Wednesday, May 23, 2018 10:54 AM
    Moderator
  • You cannot use VB6 partially in C#. VB6 means only windows forms and Com (and mostly ActiveX currently to keep it alive) while C# is .Net.

    You can use code parts of VB6 to .Net VB to use as class libraries and use them then as libraries for C#. (VB and C# generate the same assemblies). 

    VB code itself is beside Com and ActiveX hardly changed since VB6. Although it is made OOP and has therefore a more consequent use of methods, properties, constructors and classes  then it was in version 6. (Many changes are automatically made from old VB style to current VB style after pasting it in Visual Studio.)

    What you have to remember in VB and C# is that if you use Win32 apis the mnemonic names like for instance short and int (integer) have made a shift to a more current day use to one higher Int8 is gone and became int16. 


    Success
    Cor




    Wednesday, May 23, 2018 11:07 AM
  • Thank you Sabah,

    Regards,

    Sasikala

    Wednesday, May 23, 2018 11:27 AM