CryoEnix
Regular
Hey all, I'm just getting to grips with Visual C++ from VS6 at the moment as it's the fastest language I've seen so far, and I'm attempting to create a 'test dll' with it before I write my application.
The test dll contains a simple 'sum' function that returns two numbers added together, and it will link perfectly in VB6 with this code:
However, when using VB 2005.NET:
I get a BadImageFormatException error on the MsgBox line - is this a compatability issue, and how can it be overcome?
The test dll contains a simple 'sum' function that returns two numbers added together, and it will link perfectly in VB6 with this code:
Code:
Private Declare Function sum Lib "example1.dll" (ByVal x As Long, ByVal y As Long) As Long
Private Sub Command1_Click()
lblanswer.Caption = Str(sum(CInt(Text1.Text), CInt(Text2.Text)))
End Sub
However, when using VB 2005.NET:
Code:
Public Class Form1
Private Declare Function sum Lib "example1.dll" (ByVal x As Long, ByVal y As Long) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(sum(CInt(1), CInt(2)))
End Sub
End Class
I get a BadImageFormatException error on the MsgBox line - is this a compatability issue, and how can it be overcome?