using System; namespace SampledotNETDLL { public class Customer { private string msName; private int miHatSize; public Customer() //default constructor needed to access from COM. { this.CustomerName = "John Doe"; miHatSize = 12; } public void Init(string Name) { this.CustomerName = Name; Random rand = new Random(); miHatSize = rand.Next(8)+7; } public string CustomerName { get { return msName; } set { msName = value; } } public int HatSize { get { return miHatSize; } } } }
REGASM [path to assembly]
dim oCustomer set oCustomer = CreateObject("SampledotNETDLL.Customer") if err.number <> 0 then msgbox "Error " & Err.number & " Creating Customer: " & Err.description else msgbox "Customer exists: " & Cstr(not(oCustomer is nothing)) oCustomer.Init "Frank Smith" msgbox "Customer Name: " & oCustomer.CustomerName & " Hat Size: " & oCustomer.Hatsize end if
using System.Runtime.InteropServices;
[ProgID("MySample.Customer")]
Build Your Own ASP.NET Website Using C# & VB.NET