0% found this document useful (0 votes)
36 views1 page

Complete-Reference-Vb Net 6

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Complete-Reference-Vb Net 6

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Structures

Public Sub PrintDepByYear(ByVal intI As Integer, ByVal life As Integer)


For intI = 0 To DepreciationPeriodEnum.SeventhYear
Dim deprec As New Financial(53000, 3000, 10, life, )
Console.WriteLine("Year " & life & ": " & String.Format("{0:c}", _
deprec.DDBValue) & ", " & String.Format("{0:c}", _
deprec.DDBDepreciation))
life += 1
Next intI
Console.ReadLine()
End Sub

produces this output

Year 0: $50,000.00, $0.00


Year 1: $50,000.00, $10,000.00
Year 2: $40,000.00, $8,000.00
Year 3: $32,000.00, $6,400.00
Year 4: $25,600.00, $5,120.00
Year 5: $20,480.00, $4,096.00
Year 6: $16,384.00, $3,276.80

Note The code for the Financial structure is the FinancialStructure project in the Vb7cr
solution.
Structures serve other purposes beyond number crunching or simple value use. The following example shows
a structure encapsulating a collection of color properties for a given component. The properties call the
Color.FromArgb method found in the System.Drawing class, which takes three arguments representing
parameters for Red, Green, and Blue (RGB) color combinations. The structure allows the user to choose
custom RGB colors (which can be used as a palette you provide in an application). In the GridColors
structure the colors are returned as objects of System.Drawing.Color, which lets you use the colors anywhere
a parameter requires you to pass a System.Drawing.Color object:

Imports System.Drawing
Public Structure GridColors
Private colorDefault As Color

Public Sub New(ByVal red As Integer, ByVal green As Integer, _


ByVal blue As Integer) As Color
colorDefault = Color.FromArgb(red, green, blue)
End Sub

ReadOnly Property grWhite() As Color


Get
grWhite = Color.FromArgb(255, 255, 255)
End Get
End Property

ReadOnly Property grLightGray() As Color


Get
grLightGray = Color.FromArgb(192, 192, 192)
End Get
End Property

ReadOnly Property grGray() As Color


Get
grGray = Color.FromArgb(128, 128, 128)
End Get
End Property

244

You might also like