Persits Software, Inc. Knowledge Base Articles

HOWTO: Using Persits components in VB.NET

Problem Description

Persits Software products and manuals have example code for ASP (VBScript) and C#.NET, but do not include VB.NET samples. This article describes how to declare and create the objects in .NET with VBScript.


These code snippets illustrate how to create Persits objects in VB.NET for any .NET environment: an .aspx page, a code-behind file, or a desktop project. These illustrate how to give your object variables specific (early-bound) types, which gives a performance advantage over declaring them as a generic Object type.

Once an object is instantiated, its properties and methods can be called just as they would in C#.


dim Mail as ASPEMAILLib.IMailSender
Mail = new ASPEMAILLib.MailSender()


dim Jpeg as ASPJPEGLib.IASPJpeg
Jpeg = new ASPJPEGLib.ASPJpeg()


dim CM as ASPENCRYPTLib.ICryptoManager
CM = new ASPENCRYPTLib.CryptoManager()

Other AspEncrypt objects use similar syntax. Here's how to declare CryptoContext and CryptoBlob variables, for example, and examples of setting them:

dim objContext as ASPENCRYPTLib.ICryptoContext
objContext = CM.OpenContext( "", 1, Missing.Value )

dim objBlob as ASPENCRYPTLib.ICryptoBlob
objBlob = CM.CreateBlob()


dim Pdf as ASPPDFLib.IPdfManager
Pdf = new ASPPDFLib.PdfManager()

Other AspPDF objects use similar syntax. Here's one example:

dim objDoc as ASPPDFLib.IPdfDocument
objDoc = Pdf.CreateDocument(Missing.Value)


If you have an Import Namespace declaration for the wrapper library, you can omit the verbose prefix for the object names. Here's an example for AspEmail, and the other objects use the same syntax:

<%@ Import Namespace="ASPEmailLib" %>
dim Mail as IMailSender
Mail = new MailSender()

AspUpload has a separate article describing its use under .NET. AspGrid does not include a library to use it under .NET.