Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 135,151 times

Contents

Related Categories

Calling a C++ DLL from Visual Basic - The VB Code

kconcept

The VB Code

This is the easiest part of the demonstration so I wont go into detail as it is pretty much self explanatory.

Private Declare Function Resolve_Name_To_Ip _
      Lib "[Add the path to the dll you just compiled]" _
                     (ByVal pcDomainToResolve As String, _
                     ByVal szReturnIP As String, _
                     ByRef iSize As Integer) As Long
                     
Private Sub Form_Load()

  Dim sIP As String
  Dim iSize As Integer
  Dim lRetVal As Long
  Dim sDomain As String
    
    sDomain = "www.yahoo.com"
    sIP = String(20, "*")
    lRetVal = Resolve_Name_To_Ip(sDomain, sIP, iSize)
    MsgBox (Mid(sIP, 1, iSize))

End Sub

Well that just about wraps it up, but again, and I cannot stress it enough that if you run into trouble compiling the DLL make sure you have included the ws2_32.lib library in the project as explained above or you will get a ton of errors.

If you ever receive errors like, "error LNK2001: unresolved external symbol", you are most likely missing a required library. Just go ahead and add the missing library to the project and you will be good to go.

I hope this has helped you out!

Kevin Saitta is an independent Database/Programming consultant specializing in full life cycle development and database design. You can contact Kevin through the Internet at kev@kbaseonline.com.

KBaseonline.com, your #1 stop to I.T. information! Tutorials, Tips, Articles and more!

Comments

  • Re: [1973] Calling a C++ DLL from Visual Basic

    Posted by joseluiscruz on 09 Jun 2008

    How do I get a longer String back to visual basic from my visual c++ dll ?

  • the code i looked for!!!!!!!!!!!!

    Posted by guerinik_khalil on 09 Dec 2005

    thank you very much for this code. It resolves all my problems and errors. khalil from france.

  • Terrific

    Posted by tank on 25 May 2005

    [blue] This program is very useful for me, you are very terrific. Thanks [/blue]

  • Posted by ChuckSomerville on 20 Apr 2005

    Hi Caripito,

    I guess what you need is to see if there's some VBA function to return the location of the current workbook. I don't use Excel/VBA hardly at all, so I'm not familiar with any such fun...

  • Posted by caripito on 20 Apr 2005

    Hey Chuck, thank you very much for answering me... I already know haow to add a DLL in Visual Basic, in fact I guess it is hte same as stand alone VB... I do this:

    Public Declare Convert Lib "Blue...