CryoEnix Posted May 19, 2006 Posted May 19, 2006 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: 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: 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? Quote Chaos is merely logic beyond human comprehension
Leaders snarfblam Posted May 20, 2006 Leaders Posted May 20, 2006 Dotnet might be more finicky than VB6. Also, remember that a Long in VB6 is an Integer in VB.Net. You might want to look around for some tutorials for this. I'm sure you've already read at least one or two, but they might have missed a detail that VB6 tolerated, and there are plenty of them out there so you can cross reference them. Quote [sIGPIC]e[/sIGPIC]
CryoEnix Posted May 20, 2006 Author Posted May 20, 2006 Thanks marble, I'll look into it. I never knew about the integer expansion - after all these years on dot net, I'm embarrased! Quote Chaos is merely logic beyond human comprehension
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.