A simple quick overview
When a member is private it can be called by other members in the same class.
When a member is public it can be called anywhere a instance of the class is visible
also there is protected which is like private but allows derived classes to call it, and sealed etc......
When you call a member of a class you call it through a object of that class
So you have
Public Class MattClass
Sub New()
Console.WriteLine("Created")
End Sub
Public Sub MattInstanceMethod()
Console.WriteLine("Instance")
End Sub
Public Shared Sub MattSharedMethod()
Console.WriteLine("Shared")
End Sub
End Class
So
Dim mclass as New MattClass
Assigns mclass as a new instance of MattClass and calls its constructor which in VB is the Sub New
Which would print 'created' because of the constructor
Now you can call it through the object
mclass.MattInstanceMethod()
Also there are Shared members which are called from the class level.
MattClass.MattSharedMethod()
A shared method does not belong to any instance of that class.
To create a counter of how many instances of a class is created a shared field could be incremented in its constructor.
Sub Main()
MattClass.MattSharedMethod()
Dim mclass As New MattClass()
mclass.MattInstanceMethod()
Console.ReadKey()
End Sub
....
.....
....
From a form perspective all logic for counting attributes should be kept out of it.
To reuse that would mean creating a new instance of the form and calling the method.
For a basic and simple example
I am not familiar with DBX but you could create class that takes filenames and returns the number of atts using the DBX logic
Public Class DBXAttCounter
Public Function NumberOfAtts(ByVal fileName As String) As Integer
''''logic for getting atts
End Function
End Class
then from the form you have something like
Dim dbxcounter As New DBXAttCounter()
Dim i As Integer = dbxcounter.NumberOfAtts("FileName")
That way all complexity is handle by the class and any changed is handled there, so it will not affect any form, class that calls it.