Monday, May 18, 2009

EXAMPLE OF Structure in VB.NET

Structure Employee

'declaring a structure named Employee

Dim EmpName As String

Dim EmpDesignation As String

Dim EmpCity As String

Dim EmpSal As Double

Dim EmpId As Integer

'declaring five fields of different data types in the structure

End Structure

Sub Main()

Dim san As New Employee()

'creating an instance of Employee

san.EmpName =

"Sandeep"

san.EmpDesignation =

"Software Developer"

san.EmpCity =

"Sydney"

san.EmpSal = 60000

san.EmpId = 2707

'assigning values to member variables

WriteLine(

"EmpName" + " " + san.EmpName)

WriteLine(

"EmpDesignation" + " " + san.EmpDesignation)

WriteLine(

"EmpCity" + " " + san.EmpCity)

WriteLine(

"EmpSalary" + " " + san.EmpSal.ToString)

WriteLine(

"EmpID" + " " + san.EmpId.ToString)

'accessing member variables with the period/dot operator

Read()

End Sub
 
OutPut:
EmpName Sandeep
EmpDesignation Software Developer
EmpCity Sydney
EmpSalary 60000
EmpID 2707



      

No comments:

Post a Comment