How to Access a Dll for Visual Basic
Visual Basic provides programmers with the programming language that creates web and desktop applications. Visual Basic can call dynamic link libraries (DLLs), which are compiled files that have shared functions and properties. A common reason to call a DLL file is to use the Windows operating system's functions. This allows programmers to use common functions within Windows such as window creations, service creation and hardware interactivity.
Instructions
-
-
1
Create a call to the DLL file. In this example, a call to a DLL that manages the hard drives on the machine is used. The following code creates a call to the file:
Declare Sub getdiskinfo Lib "c:\myDLL" (ByVal drive As String, ByVal volume As String, free_space As Long) -
2
Create variables to send to the function and variable that contains the return value. The following code is used to declare variables in Visual Basic:
Dim drive As String
Dim volume As String
Dim free As Long
Dim returnValue As Integer -
-
3
Call the function and return a value. The following code illustrates how you use a DLL function in Visual Basic:
returnValue = getdiskinfo (drive, volume, free) -
4
Display the result to verify your function results. The message box is used to test values in Visual Basic. The following code displays the return value from the "getdiskinfo" function call:
MsgBox returnValue
-
1
References
- Photo Credit computers network image by Orlando Florin Rosu from Fotolia.com