writing/calling a .DLL in VB (visual studio 2010)
Visual Studio 2010 (VB)
I want to call the function do_barcode() in the dll AxBarcodeCG.dll
i have added a reference to axbarcode to the project containing the caller code, but when i run it i get the error "Unable to find an entry point named 'do_barcode' in DLL 'axbarcodecg'."
can anyone see what i am doing wrong?
PS i am new to VS 2010 and DLL writing.
PPS there is probably a more elegant way to build a printer escape sequence that the one i have used,. :)
thanks in advance.
// *************************************************** //
AxBarcodeCG.dll
Public Class AxBarcodeCG
Public Const DLL_PROCESS_DETACH = 0
Public Const DLL_PROCESS_ATTACH = 1
Public Const DLL_THREAD_ATTACH = 2
Public Const DLL_THREAD_DETACH = 3
Public Function DllMain(ByVal hInst As Long, ByVal fdwReason As Long,
ByVal lpvReserved As Long) As Boolean
Select Case fdwReason
Case DLL_PROCESS_DETACH
' No per-process cleanup needed
Case DLL_PROCESS_ATTACH
DllMain = True
Case DLL_THREAD_ATTACH
' No per-thread initialization needed
Case DLL_THREAD_DETACH
' No per-thread cleanup needed
End Select
End Function
Public Function do_barcode(ByVal var As String) As String
Dim myString As String
myString = Chr(27) + Chr(16) + Chr(65) + Chr(8) + Chr(4) + Chr(0) + Chr(0) + Chr(3) + Chr(1) + Chr(1) + Chr(1) + Chr(1)
myString = myString + Chr(27) + Chr(16) + Chr(66) + Chr(14) + Chr(65) + "1111-1234567" + Chr(103)
Return myString
End Function
End Class
// ************************************************************************* //
// Caller Code
Public Class Form1
Private Declare Function do_barcode Lib "axbarcodecg" (ByVal escapestr As String) As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.TextBox1.Text = do_barcode(1)
End Sub
End Class