|
-
Oct 19th, 2003, 12:18 PM
#1
Thread Starter
Hyperactive Member
PROTECTED variable question
Question: when to declare a variable as "PROTECTED" .
I created a class called as "Employee" and declared a variable as
Protected mFirstName.
After I instantiated an object of the type "Employee" class, I can't use the variable.
The error is "Employee.mFirstname is not accessible in this context because it is 'Protected'. It works if i change the scope of the mFirstName to 'Public'.
But according to the definitions I read in the books, 'Protected' variables can be accessed from Class or derived classes.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim clsBasam As clsFHLBEmployee
clsBasam = New clsFHLBEmployee("Basam Nath")
MsgBox("The Firsname of the basam is " & clsBasam.mFirstname)
End Sub
Public Class clsFHLBEmployee
Protected mFirstname As String
Public Property FirstName() As String
Get
Return mFirstname
End Get
Set(ByVal Value As String)
mFirstname = Value
End Set
End Property
Public Sub New(ByVal firstname As String)
'MsgBox("The constructor of the clsFHLBEmployee")
Me.FirstName = firstname
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|