Posted by: Sourav | August 20, 2016

Structure Example in Visual Basic,Sourav VB Faculty


Option Strict On
Option Explicit On
Imports System
Structure student
Private id As Integer
Private name As String
Sub New(ByVal id As Integer, ByVal name As String)
Me.id = id
Me.name = name

End Sub
Public Property manipulateid() As Integer

Set(ByVal id As Integer)
Me.id = id
End Set
Get
Return Me.id

End Get

End Property
Public Property manipulatename() As String

Set(ByVal name As String)
Me.name = name
End Set
Get
Return Me.name

End Get

End Property
Sub printelements()
Console.WriteLine(“The student name is {0} and student id is {1}”, Me.name, Me.id)

End Sub

End Structure
Module Module1

Sub Main()
Dim student1 As student = New student
student1.manipulateid = 1
student1.manipulatename = “Sourav”
student1.printelements()
Dim student2 As student = New student(2, “Sougata”)
student2.printelements()
Console.ReadLine()
End Sub

End Module

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: