473,386 Members | 1,745 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,386 software developers and data experts.

Get .... EndGet

Anybody can explain me what is
1. Get ..... EndGet
2. Set ...... EndSet

Please send me any example.
Nov 21 '05 #1
5 1755

Look up the Property keyword.

Mike Ober.

"Kalim Julia" <ka*********@gmail.com> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...

Anybody can explain me what is
1. Get ..... EndGet
2. Set ...... EndSet

Please send me any example.


Nov 21 '05 #2
"Kalim Julia" <ka*********@gmail.com> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
: Anybody can explain me what is
: 1. Get ..... EndGet
: 2. Set ...... EndSet
:
: Please send me any example.
They relate to properties.
As an example, say you have a variable in your class that you want to
expose. Users are allowed full access to read the variable, but you don't
want users to give the variable a value greater than 100. If you make the
variable public, users can assign any value at all to it. By using a
property however, you can trap invalid values.
----------------------------------
Private mSomeVariable As Integer

Public Property SomeVariable() As Integer
Get
Return mSomeVariable
End Get

Set '(input parameter 'value' implied)
If value > 100 Then
Throw New Exception("value cannot exceed 100")
Else
mSomeVariable = value
End If
End Set
End Property
----------------------------------
Another use would be if you want to allow users to see the value of the
variable but do not want them to be able to change it. A 'read only'
property allows that.
----------------------------------
Private mSomeVariable

Public Readonly Property SomeVariable
Get
Return mSomeVariable
End Get
End Property
----------------------------------
Ralf
--
--
----------------------------------------------------------
* ^~^ ^~^ *
* _ {~ ~} {~ ~} _ *
* /_``>*< >*<''_\ *
* (\--_)++) (++(_--/) *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.
Nov 21 '05 #3
"Kalim Julia" <ka*********@gmail.com> schrieb:
Anybody can explain me what is
1. Get ..... EndGet
2. Set ...... EndSet


Enter "Get keyword" in the documentation's index...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #4
I've tried it in my program (set validation not exceed 100)
====================================
Private mlVARIABLE As Integer
Public Property _mlVARIABLE() As Integer
Get
Return mlVARIABLE
End Get
Set(ByVal Value As Integer)
If Value > 100 Then
Throw New Exception("tidak kurang dari 100")
Else
mlVARIABLE = Value
End If
End Set
End Property

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
mlVARIABLE = 200
mSomeVariable = 153
End Sub
====================================
But when I assign mlVARIABLE = 200, it just goes through without any
validation message. Why ?

"_AnonCoward" <ab*@xyz.com> wrote in message
news:nj*********************@twister.southeast.rr. com...
"Kalim Julia" <ka*********@gmail.com> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
: Anybody can explain me what is
: 1. Get ..... EndGet
: 2. Set ...... EndSet
:
: Please send me any example.
They relate to properties.
As an example, say you have a variable in your class that you want to
expose. Users are allowed full access to read the variable, but you don't
want users to give the variable a value greater than 100. If you make the
variable public, users can assign any value at all to it. By using a
property however, you can trap invalid values.
----------------------------------
Private mSomeVariable As Integer

Public Property SomeVariable() As Integer
Get
Return mSomeVariable
End Get

Set '(input parameter 'value' implied)
If value > 100 Then
Throw New Exception("value cannot exceed 100")
Else
mSomeVariable = value
End If
End Set
End Property
----------------------------------
Another use would be if you want to allow users to see the value of the
variable but do not want them to be able to change it. A 'read only'
property allows that.
----------------------------------
Private mSomeVariable

Public Readonly Property SomeVariable
Get
Return mSomeVariable
End Get
End Property
----------------------------------
Ralf
--
--
----------------------------------------------------------
* ^~^ ^~^ *
* _ {~ ~} {~ ~} _ *
* /_``>*< >*<''_\ *
* (\--_)++) (++(_--/) *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.

Nov 21 '05 #5
"Kalim Julia" <ka*********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I've tried it in my program (set validation not exceed 100)
====================================
Private mlVARIABLE As Integer
Public Property _mlVARIABLE() As Integer
Get
Return mlVARIABLE
End Get
Set(ByVal Value As Integer)
If Value > 100 Then
Throw New Exception("tidak kurang dari 100")
Else
mlVARIABLE = Value
End If
End Set
End Property

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
mlVARIABLE = 200
mSomeVariable = 153
End Sub
====================================
But when I assign mlVARIABLE = 200, it just goes through without any
validation message. Why ?


A prioperty is only any use if you actually make use ofit.
Your code is setting the Private member variable (mlVARIABLE)
directly, bypassing the Property completely. Use

Me._mlVARIABLE = 200

instead.

BTW, I think it is customary to have the /member/ variable with
the '_'-prefixed name, and the Property with just the simple name,
as in

Private _mlVARIABLE as Integer = 0

Public Property Variable() as Integer
.. . .

then

Me.Variable = 200

HTH,
Phill W.
Nov 21 '05 #6

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

Similar topics

0
by: Steph. | last post by:
Hi, I was looking for a way to get a Panel with a Raised border style ... I found the simplest way to do it, so I share it with you : public class StpPanel:Panel { const int...
4
by: Lucvdv | last post by:
I have to connect to a server set up by the government, where they used Apache Axis to create a webservice. The code I use to interface to the webservice is generated by wsdl.exe, based on a...
4
by: Angel Mateos | last post by:
Is posible something like this? public Class Class1 property readonly InstanceName get return me.InstanceName endget end property end class
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.