ARTICLE

Property procedure in VB.NET

Posted by Satyapriya Nayak Articles | Windows Forms VB.NET August 11, 2011
Here we can store the value and also can retrieve the value using Property Procedure.
Download Files:
 
Reader Level:

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

Output

propertyprocedure.gif

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Nevron Diagram
Become a Sponsor