Skip to Main Content
VB.Net Web Developer's Guide
book

VB.Net Web Developer's Guide

by Syngress
September 2001
Intermediate to advanced content levelIntermediate to advanced
608 pages
23h 46m
English
Syngress
Content preview from VB.Net Web Developer's Guide
206 Chapter 5 • .NET Programming Fundamentals
Class SomeClass
Private Shared NumInstances As Integer = 0
Public Sub New()
NumInstances = NumInstances + 1
End Sub
Public ReadOnly Property Instances() As Integer
Get
Return NumInstances
End Get
End Property
End Class
Public Sub testShared()
Dim clsSomeClass1 As New SomeClass()
Dim clsSomeClass2 As SomeClass
Dim num As Integer
num = clsSomeClass1.Instances ' returns 1
clsSomeClass2 = New SomeClass()
num = clsSomeClass2.Instances ' returns 2
End Sub
In this example, we created a constructor that increments the NumInstances
variable.When the first class is instantiated, this variable is equal to 1.When the
second class ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VB.NET Core Classes in a Nutshell

VB.NET Core Classes in a Nutshell

Budi Kurniawan, Ted Neward

Publisher Resources

ISBN: 9781928994480