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.
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