Have a problem while create DLL!!!Need Help
-
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
-
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
Yep. the
int
type in C++ is a processor specific widht integer, usually 32-bits. TheInteger
type in VB6 is a 16-bit integer. In your VB6 app, change yourInteger
types toLong
(32-bit signed integer in VB6) and it should work. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome -
Yep. the
int
type in C++ is a processor specific widht integer, usually 32-bits. TheInteger
type in VB6 is a 16-bit integer. In your VB6 app, change yourInteger
types toLong
(32-bit signed integer in VB6) and it should work. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome