How do I use an openfiledialog box in a class?

I have a form to open a text file and count the number of characters, words, sentences and paragraphs. I am trying to use a class to do all of the work but cannot figure out how to refence labels and buttons on the form in the class? Any suggextions?

I don't know where openfiledialog box comes into the picture but it's very trivial to reference labels and buttons in a class. What you could do is in your class you could create a property like so:

Public Class YourClassName

Private formReference As frmName

Friend Property FormToAccess() As frmName
Get
FormToAccess = formReference
End Get
Set(ByVal Value As frmName)
formReference = Value
End Set
End Property
.......

End Class

And in your code behind the form, you could do something like this:

Public Class frmName
Inherits System.Windows.Forms.Form

Dim cls As YourClassName = New YourClassName
.....
cls.FormToAccess = Me 'This line assigns this form to the class's 'FormToAccess' property, hence you can access any of the forms labels or buttons using it.
....

End Class

I hope that is understandable. Cheers.

0

Featured Post

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

This article explains how to create and use a custom WaterMark textbox class. The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.
IMAGE OF WATERMARKS
STEPS
Create VB …

Introduction
Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares.
The application is written in VB.NET targeting the .NET framework 2.0.
The source code and the compiled programs have been in…

In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…