Pages

Sunday 28 July 2013

VB 11 Tutorial 10: Getting Started

VB 11 Tutorial 10: Getting Started

Today we will be learning on how to use Classes.



Code:

' Example of Using Classes

Module SubNew
Public Class Person
private cDNA(255) As Byte

Sub New(Byref DNA1() As Byte, Byref DNA2() As Byte)
For I = 0 to 255
AddByte(cDNA(I), DNA1)
AddByte(cDNA(I), DNA2)
Next
End Sub

Private Sub AddByte(byref Byte1 As Byte, Byte2 As Byte)
Dim x As Integer = Cint(Byte1) + Cint(Byte2)

If x > 255 Then
Byte1 = Cbyte(x - 256)
Else
Byte1 = Cbyte(x)
End If
End Sub

Public Property DNA() As Byte()
Get
return cDNA
End Get
Set(value() As Byte)
If value <> cDNA then
cDNA = Value
End If
End Set
End Property
End Class
End Module

No comments:

Post a Comment