By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,877 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

Get and set

P: n/a
hi

Does anyone know how to use the get and set command

thanks
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

Private _mytest As String

Public Property MyTest() As String
Get
Return _mytest
End Get
Set(ByVal Value As String)
_mytest = Value
End Set
End Property
Regards,
Josip Habjan, Croatia
URL: www.habjansoftware.com

"Yomus" <Bu*****@hotmail.com> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
hi

Does anyone know how to use the get and set command

thanks

Nov 21 '05 #2

P: n/a

"Josip Habjan" <jh*****@SPAM-OFF.net.hr> wrote in message
news:d8**********@magcargo.vodatel.hr...
Hi,

Private _mytest As String

Public Property MyTest() As String
Get
Return _mytest
End Get
Set(ByVal Value As String)
_mytest = Value
End Set
End Property
Regards,
Josip Habjan, Croatia
URL: www.habjansoftware.com

"Yomus" <Bu*****@hotmail.com> wrote in message
news:%2*****************@TK2MSFTNGP12.phx.gbl...
hi

Does anyone know how to use the get and set command

thanks


Explanation:

The Get and Set keywords are used for properties. The "Getter" is the Get
keyword (statement??) that should always return the value for the property.
The "Setter" is the Set keyword (statement??) that should always set the
value of the property. There are also instances where there would be no
set/get. In these instances, you would use another keyword on the property,
as described below:

Private mUserName As String
Private mPassword As String

Public ReadOnly Property UserName() As String
Get
Return mUserName
End Get
End Property

Public WriteOnly Property Password() As String
Set
mUserName = Value
End Set
End Property

Extra Note:

You do not need the parameter list for the Set like most programmers use.
This extra bit is for clarity I believe but I do not use it as it means
typing more ;)

Set (ByVal Value As String)
mUserName = Value
End Set

gets the same results as

Set
mUserName = Value
End Set

HTH,

Mythran

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.