Visual Studio .Net 2003 tutorial.

create a new project

Create a new project by selecting File > New > Project from the menu.
Select class library and call it maths.

Vb.net standard may not be able to create a class library. To get around this create a new project as a console application.
Close visual studio and open the projects .vbproj file in notepad. Change OutputType = "Exe" to OutputType = "Library".
Now start visual studio and reopen the project.

enter code

Methods that you want to export should be public static in c# and public shared in vb.net.
We will export two methods add and subtract.

c# code
using System;
namespace maths
{
	public class MyClass
	{
		public static int add(int a, int b)
		{
			return a + b;
		}
		public static int subtract(int a, int b)
		{
			return a - b;
		}
	}
}

vb.net code
Imports System
Namespace maths

	Public Class MyClass
		Public Shared Function add(ByVal a As Integer, ByVal b As Integer) As Integer
			Return a + b
		End Function

		Public Shared Function subtract(ByVal a As Integer, ByVal b As Integer) As Integer
			Return a - b
		End Function
	End Class 
End Namespace

build

Change the build type to release and select build > build solution from the menu to compile the dll.
You can find the dll in the projects bin\release directory.

dll tool

Start dll_tool and load the dll. The methods in the dll that can be exported are shown in the left hand methods list.
You can see the add and subtract methods we wrote there.

dll tool ready for build

Dbpro tpc(third party command) dlls use Cdecl as the calling convention so leave "the Moved methods will be" combo box as Cdecl.
Select both the add and subtract methods and click the > button to move them to the exports list.
Double clicking an item in the exports list will show a dialog that allows you to edit the export name and calling convention.

Check the "Add string table" checkbox. Dbpro uses the dll string table to find out about the commands contained within the dll.
Click the Generate button and the program will automatically produce a correct string table.
You can edit a string table item by double clicking it. Documentation on the string table can be found in the
technical documents > third party commands section of the dbpro help.

The dll is now ready to be build so click the build button to build it.

If you are going to be working on the dll in the future you can save a .dsf (dll tool settings file) to make it less work.
A dsf file contains the filename of the dll and a list of exports and any string table items.
After you have made changes to the dll load the dsf file. The dll in the dsf file will automatically be loaded and any
methods that match the exports in the dsf file will be moved to the export list and the string table items added to the
string table list.

Use the tpc in dbpro

The built dll can now be moved to the Dbpro\Compiler\Plugins-user directory and the commands used in dbpro.

dbpro code
a as integer
b as integer
c as integer

a = 50
b = 100

c = add(a,b)
print c

c = subtract(a,b)
print c
wait key