Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic Misc > Re: Calling a F...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 1443 of 1492
Post > Topic >>

Re: Calling a FreeBASIC-DLL from VB

by Wolfgang Enzinger <"Wolfgang Enzinger <weusenet"@[EMAIL PROTECTED] Mar 30, 2008 at 12:19 PM

Am Sun, 16 Mar 2008 13:09:50 +0100 schrieb Wolfgang Enzinger:

> I'm currently trying to write a DLL in FreeBASIC for calling from VB.
> However, VB seems to load the DLL but cannot find my ex****ted procedure
> whatever I try.

OK, got this one solved. For the archives ...

**** <FreeBasic code> **** 

'File: VBTest.bas
#include once "windows.bi"
#include once "win/ole2.bi"

EXTERN "windows-ms"

FUNCTION AddNumbers ( _
  BYVAL operand1 AS INTEGER, BYVAL operand2 AS INTEGER ) _
  AS INTEGER EX****T
RETURN operand1 + operand2
END FUNCTION

FUNCTION UpperCase(BYVAL arg AS ZSTRING PTR) AS BSTR EX****T
DIM res AS BSTR, s AS STRING
s = UCASE(*arg)
res = SysAllocStringByteLen(STRPTR(s), LEN(s))
RETURN res
END FUNCTION

END EXTERN 

**** </FreeBasic code> ****

Compilation:
fbc.exe -dll -ex****t VBTest.bas


**** <VB code> **** 
Option Explicit

Declare Function AddNumbers _
  Lib "VBTest.dll" _
  (ByVal operand1 As Long, ByVal operand2 As Long) _
  As Long
  
Declare Function UpperCase _
  Lib "VBTest.dll" _
  (ByVal s As String) _
  As String

Sub main()
Debug.Print AddNumbers(1, 2)
Debug.Print UpperCase("this is a test")
End Sub

**** </VB code> **** 

> Wolfgang
 




 2 Posts in Topic:
Calling a FreeBASIC-DLL from VB
Wolfgang Enzinger <weu  2008-03-16 13:09:50 
Re: Calling a FreeBASIC-DLL from VB
Wolfgang Enzinger <&qu  2008-03-30 12:19:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 1:18:29 CDT 2008.