Alrighty! newb api VB tutorial coming up.

API is a piece of cake. If you know how to use a function in VB then you know how to use API. Example, take this function,


CODE
Private Function MyFunc(ByVal x As Integer, ByVal y As Integer) As Integer

   MyFunc = x * y   ' 3 and 4 get passed to here

End Function



CODE
Private Sub Command1_Click()

MsgBox MyFunc(3, 4)  ' gives you 12, or returns 12

End Sub


Returns 12 if you feed the function 3 and 4.


API is exactly the same except the functions are stored in Dll's, like msvbvm60.dll, user32.dll etc...

So you pass values to those funtions in the dlls and you get a return value or so.

So if there was a function in a dll called MyFunc, you first have to declare the function in your vb program first such as

CODE

Private Declare Function MyFunc Lib "path to dll" (ByVal x As Integer, ByVal y As Integer) As Integer


then simply call it from your app,


CODE
Private Sub Command1_Click()

   MsgBox MyFunc(3, 4)  ' gives you 12, or returns 12

End Sub


Thats basically API.

 

 

 


Reply