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. Have a problem while create DLL!!!Need Help

Have a problem while create DLL!!!Need Help

Scheduled Pinned Locked Moved Visual Basic
c++helpdatabasedata-structures
3 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.
  • J Offline
    J Offline
    john_tran
    wrote on last edited by
    #1

    I create a DLL in VC++, call VD.DLL, and include file VD.CPP, its contain: int _stdcall VD(int *index) { int i; for(i=0;i<5;i++) index[i] = i; return (i); } In VB6.0, i declare to use this DLL: Private Declare Function VD "my-dll-path" (ByRef intIndex as integer) as Integer And use this function in VB's body like this: Dim intIndex(0 to 50) as Integer //Global Integer Array Sub VD() Dim i as integer, intI as Integer intI = VD(intIndex) for i=0 to intI-1 MsgBox "Value " & i & " = " & intIndex(i) Next End Sub And It shows : Value 0 = 0 Value 1 = 0 'Unexpectly Value 2 = 1 Value 3 = 0 'Unexpectly Value 4 = 2 The second and fourth line is not correct. Because in my case, i must show: Value 0 = 0 Value 1 = 1 Value 2 = 1 Value 3 = 3 Value 4 = 4 Why this happen? Anything wrong in my code? Thanks Ask More - Learn More JohnJone

    D 1 Reply Last reply
    0
    • J john_tran

      I create a DLL in VC++, call VD.DLL, and include file VD.CPP, its contain: int _stdcall VD(int *index) { int i; for(i=0;i<5;i++) index[i] = i; return (i); } In VB6.0, i declare to use this DLL: Private Declare Function VD "my-dll-path" (ByRef intIndex as integer) as Integer And use this function in VB's body like this: Dim intIndex(0 to 50) as Integer //Global Integer Array Sub VD() Dim i as integer, intI as Integer intI = VD(intIndex) for i=0 to intI-1 MsgBox "Value " & i & " = " & intIndex(i) Next End Sub And It shows : Value 0 = 0 Value 1 = 0 'Unexpectly Value 2 = 1 Value 3 = 0 'Unexpectly Value 4 = 2 The second and fourth line is not correct. Because in my case, i must show: Value 0 = 0 Value 1 = 1 Value 2 = 1 Value 3 = 3 Value 4 = 4 Why this happen? Anything wrong in my code? Thanks Ask More - Learn More JohnJone

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Yep. the int type in C++ is a processor specific widht integer, usually 32-bits. The Integer type in VB6 is a 16-bit integer. In your VB6 app, change your Integer types to Long (32-bit signed integer in VB6) and it should work. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      J 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Yep. the int type in C++ is a processor specific widht integer, usually 32-bits. The Integer type in VB6 is a 16-bit integer. In your VB6 app, change your Integer types to Long (32-bit signed integer in VB6) and it should work. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        J Offline
        J Offline
        john_tran
        wrote on last edited by
        #3

        I changed The value to Short Int (in CPP file), and it work exactly Thanks. Ask More - Learn More JohnJone

        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