AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Syed Rizwan Muhammad Rizvi
Expertise
I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.

Experience
Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > DLL calling a function in a VB program

Topic: VB.NET



Expert: Syed Rizwan Muhammad Rizvi
Date: 3/7/2008
Subject: DLL calling a function in a VB program

Question
Hello,

VS 2008

I have created a C++ smart device DLL and added it to my project.

From my VB program I can call the functions successfully in the DLL. Using the code below

CODE
<DllImportAttribute("WIN32SmartDLL.dll")> _
Private Shared Function AddNumbers(ByVal a As Integer, ByVal b As Integer) As Integer
End Function

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
   Dim answer As Integer = AddNumbers(25, 25)
   
End Sub

However, I need to be able to get the DLL to get information from the VB program.

So basically I have a function in my VB program, and I want a DLL function to call this function.

So DLL will be call a VB function.
Many thanks for any advice on this,

Steve
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
   Dim answer As Integer = AddNumbers(25, 25)
   
End Sub

Answer
Rather than asking you to write wrappers etc. I would suggest that an easier way would be to write another function inside the C++ DLL which accepts the information that you want to be passed from VB to C++ and store it for later use. You can make an init function and before any other function in the DLL is called you can check whether init has been called or not and act accordingly.

Let me know if you have further questions.

Regards,
Riz

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.