calling namespace / class and sub via button click

In VB.net I would call following code when user clicks on the button


Imports System.IO
Imports Aquaforest.OCR.Api

Namespace OCRImagePDF
	Class Program
		Private Shared Sub Main(args As String())
			Try
				Dim ocr As New Ocr()
				Dim preProcessor As New PreProcessor()

				Dim OCRFiles As String = Path.GetFullPath("..\..\..\..\..\bin\")
				Environment.SetEnvironmentVariable("PATH", Convert.ToString(Environment.GetEnvironmentVariable("PATH") + ";") & OCRFiles)
				ocr.ResourceFolder = OCRFiles

				ocr.EnableConsoleOutput = True
				ocr.Language = SupportedLanguages.English
				ocr.EnablePdfOutput = True

				preProcessor.Deskew = True
				preProcessor.Autorotate = False

				ocr.ReadPDFSource(Path.GetFullPath("..\..\..\..\documents\source\image_pdf.pdf"))
				If ocr.Recognize(preProcessor) Then
					ocr.SavePDFOutput(Path.GetFullPath("..\..\..\..\documents\output\searchable.pdf"), True)
				End If

				ocr.DeleteTemporaryFiles()
			Catch e As Exception
				Console.WriteLine("Error in OCR Processing :" + e.Message)
			End Try
		End Sub
	End Class
End Namespace

Open in new window

LVL 5
CalmSoulAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ChloesDadCommented:
Am I missing something, what are you asking as there is no question, just a statement of what you do.
Fernando SotoRetiredCommented:
What exactly is the question you are asking giving as much info as you can. Is the above code in a separate dll or part of the same project that you are writing?
CalmSoulAuthor Commented:
I have this namespace mentioned in the question above, I would like to call this on button click - how to do it ?
ChloesDadCommented:
If this module is already included in the solution then

OCRImagePDF.Program.Main(param)

Open in new window


However you will also need to change it to Public rather than private as otherwise you wont see it outside the class
David Johnson, CD, MVPOwnerCommented:
add
Import OCRImagePDF
to import the namespace

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.