Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

app runs in vb environment but not as an exe

Status
Not open for further replies.

Galyl

Programmer
Nov 21, 2001
16
0
0
ZA
Ive written an app in vb6, in runs perfectly in the vb environment, but when i compile it i get the following error:
Run-time error '5':
Invalid procedure call or argument

this error occurs after a call to a C dll. The dll gets initialised, it retrieves the data it is supposed to from the com port, but when it sends a return code to my vb app, the error occurs.

It runs perfectly in VB. Does anyone have any idea why this happens?

Thanks for your time

 
It sounds like you're passing a string to the C dll. If so, make sure you initialize the string to spaces (or something) before doing this. The way VB and C handle strings are very different, and for the two to talk correctly you need to allocate some memory for the C dll to write into...and you do this by initializing the string first.

Dim MyString as string

MyString = space$(400)
call MyDllFunction(MyString)

(assuming that the DLL will never write more than 399 ASCII characters to the string).

Chip H.
 
The function im calling is declared as follows :

Private Declare Function BcpSend Lib "vc2vb.dll" (ByVal cmd As Integer, ByVal address As Byte) As Byte

and is called as :

iRet = BcpSend(151, iaddr)

where iRet and iaddr are both bytes. Havnt chaged the names, the were bith integers when i defined them.

iRet get set to 0 before the function call
iaddr contains a variable retrieved from a database
 
I changed iRet from byte to long, that has solved the problem.

Thanks for the replying
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top