.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Property procedure in vb.net

Posted By:satyapriyanayak       Posted Date: March 11, 2013    Points: 40    Category: ADO.NET    URL: http://www.dotnetspark.com  

Property procedure. in this code we can store the value and also can retrieve the value.
 

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

        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

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend