Property Procedure in

Posted by Satyapriyanayak under VB.NET category on | Points: 40 | Views : 1266
Property Procedure: - Here we can store the value and also can retrieve the value. 

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.


Public Class Form1

Dim age As Integer
Private Property Y() As Integer
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")
Y = TextBox1.Text
Catch ex As Exception
End Try
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

Comments or Responses

Login to post response