30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

770 Files and Streams Chapter 17<br />

1 ' Fig. 17.8: CRecord.vb<br />

2 ' Serializable class that represents a data record.<br />

3<br />

4 Public Class CRecord<br />

5<br />

6 Private mAccount As Integer<br />

7 Private mFirstName As String<br />

8 Private mLastName As String<br />

9 Private mBalance As Double<br />

10<br />

11 ' default construc<strong>to</strong>r sets members <strong>to</strong> default values<br />

12 Public Sub New()<br />

13 Me.New(0, "", "", 0.0)<br />

14 End Sub ' New<br />

15<br />

16 ' overloaded construc<strong>to</strong>r sets members <strong>to</strong> parameter values<br />

17 Public Sub New(ByVal accountValue As Integer, _<br />

18 ByVal firstNameValue As String, _<br />

19 ByVal lastNameValue As String, _<br />

20 ByVal balanceValue As Double)<br />

21<br />

22 Account = accountValue<br />

23 FirstName = firstNameValue<br />

24 LastName = lastNameValue<br />

25 Balance = balanceValue<br />

26 End Sub ' New<br />

27<br />

28 ' property Account<br />

29 Public Property Account() As Integer<br />

30<br />

31 Get<br />

32 Return mAccount<br />

33 End Get<br />

34<br />

35 Set(ByVal accountValue As Integer)<br />

36 mAccount = accountValue<br />

37 End Set<br />

38<br />

39 End Property ' Account<br />

40<br />

41 ' property FirstName<br />

42 Public Property FirstName() As String<br />

43<br />

44 Get<br />

45 Return mFirstName<br />

46 End Get<br />

47<br />

48 Set(ByVal firstNameValue As String)<br />

49 mFirstName = firstNameValue<br />

50 End Set<br />

51<br />

52 End Property ' FirstName<br />

Fig. 17.8 CRecord class represents a record for sequential-access file-processing<br />

applications (part 1 of 2).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!