Feeds:
Posts
Comments

Archive for the ‘OOP’ Category

A Note on Variable Scope

What about that “Private Sub MessageUser()” line from our previous example? It’s a private sub, as the name states, but try to access it from outside the Vehicle class. In the MainForm_Load() sub, try adding Van.MessageUser. You should get a build error that states ‘Vehicle.Private Sub MessageUser()’ is not accessible in this context because it [...]

Read Full Post »

Classes vs. Objects

I know I said this was object-oriented programming. So why am I talking about classes? The answer to this question is that all objects are classes. (Mind-blowing, huh?) The way to separate the difference between objects and classes is quite easy. An object has an IS-A relationship, while a class has a HAS-A relationship.
A car [...]

Read Full Post »

Get() and Set() Class Property

Public Class Hello
Private _sample As String
Public Property Sample() As String
Get
‘1
Return _sample
End Get
Set(ByVal Value As String)
‘2
_sample = Value
End Set
End Property
Public Sub DoSomething()
Me.Sample = “SampleText” ‘2
MessageBox.Show(Me.Sample) ‘1
End Sub
End Class

Read Full Post »