473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

private variable vs. actual property in a class module?

What's the difference in using the private variable as opposed to the actual
property in a class module? Which is better or more efficient? (
LoginObject.Save (_loginName) or LoginObject.Save (me.LoginName)

FOR EXAMPLE:

Class MyClass

Private _loginName As String
Public Property LoginName() As String
Get
Return _loginName
End Get
Set(ByVal Value As String)
_loginName = Value.ToLower()
End Set
End Property

public sub Save()
dim LoginObject as new Data.LoginObject
'****** what is the difference in these 2 lines? *******
LoginObject.Save (_loginName)
LoginObject.Save (me.LoginName)
'******************************************
end function

End Class
Thank You,

SteveS
Jul 21 '05 #1
1 1656
I don't think it makes any difference the JIT will optimize the Me.LoginName
so there won't be any performance difference.

In my opinion using the property (Me.LoginName) is advisable, because in
that case you're using OO encapsulation.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"SteveS" <ss*****@trendmls.com> wrote in message
news:eu**************@TK2MSFTNGP09.phx.gbl...
What's the difference in using the private variable as opposed to the actual property in a class module? Which is better or more efficient? (
LoginObject.Save (_loginName) or LoginObject.Save (me.LoginName)

FOR EXAMPLE:

Class MyClass

Private _loginName As String
Public Property LoginName() As String
Get
Return _loginName
End Get
Set(ByVal Value As String)
_loginName = Value.ToLower()
End Set
End Property

public sub Save()
dim LoginObject as new Data.LoginObject
'****** what is the difference in these 2 lines? *******
LoginObject.Save (_loginName)
LoginObject.Save (me.LoginName)
'******************************************
end function

End Class
Thank You,

SteveS

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: gabor | last post by:
hi, as far as i know in python there aren't any private (i mean not accessible from the outside of the object) methods/fields. why? in java/c++ i can make a method private, this way...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
2
by: Bob | last post by:
Is this a bug? Expected behavior? Did I get the binding flags wrong? Bob -------------------- Imports System.Reflection Module Main
7
by: Just Me | last post by:
I have a project that contains a usercontrol, some forms and a module. The only thing in the module is one variable that is there so that it can be used by the control and all the forms. ...
2
by: dumbo | last post by:
Hello, who gives one more shining solution to me? My application load form "A". The form "A" by means of a push-button load form "B" that in its turn by means of a push-button load form "C". Form...
1
by: SteveS | last post by:
What's the difference in using the private variable as opposed to the actual property in a class module? Which is better or more efficient? ( LoginObject.Save (_loginName) or LoginObject.Save...
11
by: prefersgolfing | last post by:
I'm trying to find on MSDN, or someplace, that speaks to variables being public or private by default. Anyone know where? Thanks.
7
by: Victor | last post by:
I just tried a test comparing a Function to a Private Function with this code: <% Option Explicit dim X1 X1 = 9 Private Function RealTest(here) RealTest = here + X1 End Function
17
by: Peng Yu | last post by:
Hi, I'm wondering if there is something in namespace like the 'private' keyword in class? I want to define some class or function that can only be used within that namespace. Thanks, Peng
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.