why we use property ?
please let me know ...
Thanks...
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
sanjeev pandeyPosted Mar 19, 2013, 8:31 AM
Satyapriya NayakPosted Mar 12, 2013, 8:16 AM
1.Enclosed within Property and End Property.
2.It uses two blocks known as Get and Set.
3.Set-> End Set, used for storing the value.
Get-> End Get, used for returning or retrieving the value.
4.It returns the value.
5.It supports ByVal but not support ByRef.
Program
Public Class Form1
Dim age As Integer
Private Property Y() As Integer
Get
Return age
End Get
Set(ByVal Value As Integer)
age = Value
MsgBox("Age set")
End Set
End Property
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("Please enter your age")
Else
Try
Y = TextBox1.Text
Catch ex As Exception
MsgBox(ex.Message)
End Try
TextBox1.Clear()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox("Your age is: " & Y)
End Sub
End Class
Deepak VermaPosted Mar 12, 2013, 4:45 AM
I hope this blog will help you understand property:
http://blogs.msdn.com/b/vbteam/archive/2009/09/04/properties-vs-fields-why-does-it-matter-jonathan-aneja.aspx