none
Need C++ Math functions for VB.NET RRS feed

  • Question

  • There are a couple C++ era functions that have no equivalent under System.Math: 

    • frExp
    • modF

    What I wanted to do was write a C++ DLL that gets  called from VB.NET

    However, it's odd that these 2 functions are unavailable under system.math. So, i'm thinking the reason is because they can be calculated using a few available .NET functions.

    Is there something that can be done to either utilize existing .NET framework methods or would I have to actually create the C++ class?

    Thanks

    Thursday, August 21, 2008 2:06 PM

Answers

  • Declare Function frexp Lib "MSVCRT.dll" (ByVal x As Double, <Out()> ByRef intptr As Integer) As Double; 
     
    Declare Function modf Lib "MSVCRT.dll" (ByVal x As Double, <Out()> ByRef intptr As Double) As Double;

    *Disclaimer* I've converted this from a C# import so might have made a few errors converting to VB! I don't really program in VB very much!
    • Edited by Neil Tippett Thursday, August 21, 2008 2:45 PM swapped second parameter type!
    • Marked as answer by EricEricEricEric Monday, August 25, 2008 3:26 PM
    Thursday, August 21, 2008 2:44 PM
  • VB does have an equivalent, it's in the System.Runtime.InteropServices namespace. Sorry should have been clearer on that. Congrats on getting around the problem though.
    Monday, August 25, 2008 11:34 AM

All replies

  • Declare Function frexp Lib "MSVCRT.dll" (ByVal x As Double, <Out()> ByRef intptr As Integer) As Double; 
     
    Declare Function modf Lib "MSVCRT.dll" (ByVal x As Double, <Out()> ByRef intptr As Double) As Double;

    *Disclaimer* I've converted this from a C# import so might have made a few errors converting to VB! I don't really program in VB very much!
    • Edited by Neil Tippett Thursday, August 21, 2008 2:45 PM swapped second parameter type!
    • Marked as answer by EricEricEricEric Monday, August 25, 2008 3:26 PM
    Thursday, August 21, 2008 2:44 PM
  • Thanks Neil.

    Unfortunately, VB does not have an equvilant for <out()> attribute.

    The good news is that I just dont need to support those 2 functions like I had thought.


    Thursday, August 21, 2008 5:59 PM
  • VB does have an equivalent, it's in the System.Runtime.InteropServices namespace. Sorry should have been clearer on that. Congrats on getting around the problem though.
    Monday, August 25, 2008 11:34 AM