Neuralyst Technical Note: 14-5

Release Date: 2-December-1994

Affected Versions: Neuralyst Run-time Library - all versions

Symptoms: When declaring and calling Neuralyst Run-time Library DLL functions which specify a return type of “String” in Excel Visual Basic, a General Protection Failure, crash, or other errors occur.

Problem: A DLL cannot return a simple pointer to string to Visual Basic. Visual Basic expects return values of type “String” to be pointers to BSTR’s, a more complex data type. Solution: The Neuralyst DLL functions which return pointers to strings can be declared to return “Long”. The conversion routine listed below will then copy the contents at the pointer into a Visual Basic string. Declare Function lstrcpy Lib "KERNEL" (ByVal lpstr1 As Any, ByVal lpstr2 As Any) As Long Function lptostr(lp As Long) As String Dim buf As String buf = Space$(256) lp = lstrcpy(buf, lp) lptostr = buf End Function Used as follows for the example call of SetParams: Declare Function SetParams Lib "NEUR14.DLL" (t1 As Double, t2 As Double, t3 As Double, t4 As Double, t5 As Double) As Long Sub test() Dim n As String * 30 Dim i As Integer n = lptostr(SetParams(0.1, 0.3, 0.9, 0.5, 0.1)) i = MsgBox(n) End Sub


Return to Top | Home Page | Up One Level | Previous Page | Next Page
Cheshire Engineering Corporation
650 Sierra Madre Villa, Suite 201
Pasadena, California 91107
+1 626 303 1602 Neuralyst Sales
+1 626 303 1602 Customer Service and Support
+1 626 303 1590 FAX
EMAIL to <Neuralyst@CheshireEng.com>.

Copyright © 1995-1999 Cheshire Engineering Corporation. All Rights Reserved