|
-
January 1st, 2000, 08:57 PM
#1
C - VB type conversion problem?
Hi, could anyone please shed some light on what I'm doing wrong?
I'm trying to get a true value from a C function, but it always returns false.
In my C DLL, I have the function header as
BOOL Open(PSTR filename)
in my VB project, I first have the declaration as:
private Declare Function OpenDB Lib "DataBase.dll" Alias "Open" (byval txtFile as string) as Long
and then, as a procedure:
private Sub Form_Load()
Dim opened as Long
opened = OpenDB("theDB")
If opened = 1 then
lblRecordCounter = "DATABASE OPENED"
else
lblRecordCounter = "DATABASE CLOSED"
End If
End Sub
I don't get any errors, just a "DATABASE CLOSED" all the time rather than a "DATABASE OPENED".
Can anyone please tell me what I'm doing wrong?
Thanks for any help
Mark.
-
January 2nd, 2000, 06:42 AM
#2
Re: C - VB type conversion problem?
Have you checked what the return value is?
Debug.Print OpenDB("theDB")
Crazy D :-)
"One ring rules them all"
-
January 3rd, 2000, 05:23 AM
#3
Re: C - VB type conversion problem?
better change your VB code to
if opened = 0 then
...database closed"
else
... database opened
end if
even better: make your C-DLL an ActiveX dll and raise an error that can be trapped by the VB program. That way, you'd be able to give the VB client some useful error information.
-
January 3rd, 2000, 07:35 PM
#4
Re: C - VB type conversion problem?
-
January 4th, 2000, 03:21 AM
#5
Re: C - VB type conversion problem?
Can you modify the dll to see if the parameters gets there correct?
Crazy D @ Work :-)
-
January 6th, 2000, 09:00 AM
#6
Re: C - VB type conversion problem?
I discovered that if a string is passed, the function looks for that name, and opens the file.
To create a new file, a null pointer must be passed. Any ideas how to do this?
I tried
openDB(null)
openDB("")
but none seemed to work.
-
January 6th, 2000, 01:11 PM
#7
Re: C - VB type conversion problem?
To pass an empty string try to do with "vbNull". I havent tried this for calls,
but in comparisons it works. Have a try !
;-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|