Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. converting vb double to vc double

converting vb double to vc double

Scheduled Pinned Locked Moved Visual Basic
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 572417
    wrote on last edited by
    #1

    I know VB doubles are 4bits while VC doubles are 8. I'm passing a double from vb to a vc dll, how do I convert the data back and forth?

    N 1 Reply Last reply
    0
    • U User 572417

      I know VB doubles are 4bits while VC doubles are 8. I'm passing a double from vb to a vc dll, how do I convert the data back and forth?

      N Offline
      N Offline
      Nic Rowan
      wrote on last edited by
      #2

      I don't know where you saw that VB doubles are 4 bit but they're not. They're exactly the same as VC doubles... From MSDN Visual Basic reference: Double data type A data type that holds double-precision floating-point numbers as 64-bit numbers in the range -1.79769313486231E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values. The number sign (#) type-declaration character represents the Double in Visual Basic. look up "type conversion functions"


      Beware the chickens, for in their silence, they plot... Two fish are in a tank. One says to the other: "I'll man the guns, you drive!" Life is too short to be taken seriously. -- Oscar Wilde


      U 1 Reply Last reply
      0
      • N Nic Rowan

        I don't know where you saw that VB doubles are 4 bit but they're not. They're exactly the same as VC doubles... From MSDN Visual Basic reference: Double data type A data type that holds double-precision floating-point numbers as 64-bit numbers in the range -1.79769313486231E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values. The number sign (#) type-declaration character represents the Double in Visual Basic. look up "type conversion functions"


        Beware the chickens, for in their silence, they plot... Two fish are in a tank. One says to the other: "I'll man the guns, you drive!" Life is too short to be taken seriously. -- Oscar Wilde


        U Offline
        U Offline
        User 572417
        wrote on last edited by
        #3

        From what I understand the structure byte alignments for vb vs vc are 4 bytes and 8 bytes respectively. VB dynamically decides the byte alignment which is usually 4 but it can change it to optimize class structures. The reason I'm asking this is I'm passing a structure with a double array inside it from VB to a VC dll. When I change the value of the double array inside the dll, it doesn't change the vb value. I'm passing by reference. Here is my vb code: Public Type assetvar cutoff_prin_bal(400) As Double End Type Public Type collateralvar subissue(100) As Integer asset As assetvar End Type Public Declare Function test Lib "PSAEngine.dll" Alias "_test@8" _ (ByVal j As Integer, ByRef collateral As collateralvar) As Double The vc dll is: struct assetvar { double cutoff_prin_bal[400]; }; struct collateralvar { int subissue[100]; struct assetvar asset; }; __declspec( dllexport ) double test(int j, struct collateralvar *collateral); Here is what I am doing inside the dll function: __declspec( dllexport ) double test(int j, struct collateralvar *collateral) { collateral->asset.cutoff_prin_bal[j]=14; return(1); } from VB I'm calling the dll this way: dim x as double collateral.asset.cutoff_prin_bal(0) = 423149.74 x = test(0, collateral) I still get 423149.74 instead of 14.0. Therefore they are not the same thing.

        N 1 Reply Last reply
        0
        • U User 572417

          From what I understand the structure byte alignments for vb vs vc are 4 bytes and 8 bytes respectively. VB dynamically decides the byte alignment which is usually 4 but it can change it to optimize class structures. The reason I'm asking this is I'm passing a structure with a double array inside it from VB to a VC dll. When I change the value of the double array inside the dll, it doesn't change the vb value. I'm passing by reference. Here is my vb code: Public Type assetvar cutoff_prin_bal(400) As Double End Type Public Type collateralvar subissue(100) As Integer asset As assetvar End Type Public Declare Function test Lib "PSAEngine.dll" Alias "_test@8" _ (ByVal j As Integer, ByRef collateral As collateralvar) As Double The vc dll is: struct assetvar { double cutoff_prin_bal[400]; }; struct collateralvar { int subissue[100]; struct assetvar asset; }; __declspec( dllexport ) double test(int j, struct collateralvar *collateral); Here is what I am doing inside the dll function: __declspec( dllexport ) double test(int j, struct collateralvar *collateral) { collateral->asset.cutoff_prin_bal[j]=14; return(1); } from VB I'm calling the dll this way: dim x as double collateral.asset.cutoff_prin_bal(0) = 423149.74 x = test(0, collateral) I still get 423149.74 instead of 14.0. Therefore they are not the same thing.

          N Offline
          N Offline
          Nic Rowan
          wrote on last edited by
          #4

          OK I see what you're trying to do but I haven't done VC in so long I've forgotten most of it :-O. I'm sure there's something I'm missing but I can't put my finger on it... Sorry.


          Beware the chickens, for in their silence, they plot... Two fish are in a tank. One says to the other: "I'll man the guns, you drive!" Life is too short to be taken seriously. -- Oscar Wilde


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups