# CodeGuru Technical FAQs > CodeGuru Individual Visual Basic FAQs >  VB.NET API General : How Do I Use The API in VB.NET

## HanneSThEGreaT

*Q:* How do I use APIs in .NET?

*A:* If you come from a VB 6 background, you probably are accustomed to Declaring APIs like :


```
Private Declare Function SetSysColors Lib "user32" _
(ByVal nChanges As Long, lpSysColor As _
Long, lpColorValues As Long) As Long
```

The breakdown of this can be:
Declare indicates that you will be using an "external" function.SetSysColors is the name of the external functionLib "user32" Indicates that the SetSysColor function is present in the User32.dllThen the argumants are listed in brackets

If you were to use the exact same declaration inside VB.NET, you would notice that it is acceptable.

*Q:* But, is it really?

*A:* Well, it should logically work, but you may not always get away with this declaration inside VB.NET

*Q:* Why?

*A:* The major headache would be the datatypes.  Sometime an API would be declared using Integers and it will not work properly.  In this article, I've outlined the Unmanaged types. In VB 6, we could have used a Long type variable to hold the value of a Window's handle, in VB.NET we must and should use the IntPtr type variable.

*Q:* What should the proper Declaration in .NET look like?

*A:* Before we get there, we must know about the System.RunTime.InterOpSevices Namespace and DLLImport

*Q:* What are the Memebers of DLLImport:
*A:*
BestFitMapping

CallingConvention

CharSet

EntryPoint

ExactSpelling

PreserveSig

SetLastError

ThrowOnUnmappableChar

Based on this, it is clear that we should Import the System.RunTime.InterOpSevices Namespace, at the top of your form ( above everything else ) for example :


```
Imports System.Runtime.Interopservices 'Import
Public Class Form1
```

And then, declare the API in the following way:


```
    <DllImport("User32", EntryPoint:="SetSysColors")> _
    Private Shared Function SetSysColors(ByVal nChanges As Int32, ByRef lpSysColor As Int32, ByRef lpColorValues As Int32) As Int32
    End Function
```

The breakdown is as follows:
DLLImport indcates that we are "importing" a function present in an external dllUser32, means that we are using User32.dll hereEntryPoint, which is a named argument, is used to indicate which function we are going to usePrivate Shared Fuction, means indicates the name of the function, for VB purposesThen, the argument list in brackets.  If you look closely, you will notice the Datatype differences between the VB 6 version ( as stated above ), and the .NET version.

*Q:* Is there an equivalent tool to VB6's API Text Viewer?

*A:* Yes, you can download it from here :
API Text Viewer 2004

----------

