That did it.
Thanks, I knew I could count on you guys!!
Kerry
Announcement
Collapse
No announcement yet.
passing strings VB.net to PB9
Collapse
X
-
Kerry,
The code below seems to work for me with:
- PBWin 9.0 for the dll
- Visual Basic 2005 Express Edition for the calling program.
the PB dll:
Code:#COMPILE DLL "Test.dll" #DIM ALL #INCLUDE "Win32Api.Inc" FUNCTION ReverseString ALIAS "ReverseString" (BYVAL X AS STRING) EXPORT AS STRING LOCAL S$ S$ = STRREVERSE$(X) MSGBOX "In PB dll:" + S$ FUNCTION = S$ + " test dll" END FUNCTION '-------------------------------------------------------------- FUNCTION LIBMAIN(BYVAL hInstance AS DWORD, BYVAL fwdReason AS DWORD, BYVAL lpvReserved AS DWORD) EXPORT AS LONG LIBMAIN = 1 END FUNCTION '--------------------------------------------------------------
Code:[B]Imports System.Threading Imports System.Runtime.InteropServices[/B] Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sS As String sS = "Eddy" MsgBox("Answer of dll:" + [B]MyClss[/B].ReverseString(sS)) End Sub End Class
Code:Public Class [B]MyClss[/B] Declare [B]Ansi [/B]Function ReverseString Lib "Test.dll" (ByVal a As String) As String End Class
Last edited by Eddy Van Esch; 9 Dec 2008, 02:05 PM.
Leave a comment:
-
Originally posted by Walter Thompson View PostHi Kerry;
Code:'This should work. FUNCTION ReverseString ALIAS "ReverseString" (BYREF X AS STRING) EXPORT AS STRING 'Items passed BYVAL cannot be changed. FUNCTION ReverseString ALIAS "ReverseString" (BYVAL X AS STRING) EXPORT AS STRING
Thanks.
Leave a comment:
-
Passing Strings
Hi Kerry;
Code:'This should work. FUNCTION ReverseString ALIAS "ReverseString" (BYREF X AS STRING) EXPORT AS STRING 'Items passed BYVAL cannot be changed. FUNCTION ReverseString ALIAS "ReverseString" (BYVAL X AS STRING) EXPORT AS STRING
Leave a comment:
-
passing strings VB.net to PB9
sending a string to a DLL I made a function in the DLL:
FUNCTION ReverseString ALIAS "ReverseString" (BYVAL X AS STRING) EXPORT AS STRING
MSGBOX X
A$ = X
MSGBOX A$
S$ = STRREVERSE$(X)
FUNCTION = S$ + " test dll"
END FUNCTION
the first message box shows the string the second shows blanks and the only thing that comes back from the function is " test dll"
the declare in VB.NET is:
<DllImport("TESTDLL.DLL")> _
Public Shared Function ReverseString(ByVal X As String) As String
End Function
Does anyone have an answer in passing a string to a native DLL?
ThanksTags: None
Leave a comment: