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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 17 Files and Streams 769<br />

67 txtFirstName.Text = values(TextBoxIndices.FIRST)<br />

68 txtLastName.Text = values(TextBoxIndices.LAST)<br />

69 txtBalance.Text = values(TextBoxIndices.BALANCE)<br />

70 End If<br />

71<br />

72 End Sub ' SetTextBoxValues<br />

73<br />

74 ' return TextBox values as String array<br />

75 Public Function GetTextBoxValues() As String()<br />

76<br />

77 Dim values(TextBoxCount) As String<br />

78<br />

79 ' copy TextBox fields <strong>to</strong> String array<br />

80 values(TextBoxIndices.ACCOUNT) = txtAccount.Text<br />

81 values(TextBoxIndices.FIRST) = txtFirstName.Text<br />

82 values(TextBoxIndices.LAST) = txtLastName.Text<br />

83 values(TextBoxIndices.BALANCE) = txtBalance.Text<br />

84<br />

85 Return values<br />

86 End Function ' GetTextBoxValues<br />

87<br />

88 End Class ' FrmBankUI<br />

Fig. 17.7 FrmBankUI class is the base class for GUIs in our file-processing<br />

applications (part 3 of 3).<br />

To reuse class FrmBankUI, we compile the GUI in<strong>to</strong> a DLL library by creating a<br />

project of type Windows Control Library (the DLL we create is called BankLibrary).<br />

This library, as well as all the code in this book, can be found on the CD accompanying<br />

this book and at our Web site, www.deitel.com. <strong>How</strong>ever, students might<br />

need <strong>to</strong> change the reference <strong>to</strong> this library, as it most likely resides in a different location<br />

on their systems.<br />

Figure 17.8 contains the CRecord class that the programs of Fig. 17.9, Fig. 17.11 and<br />

Fig. 17.12 use for reading records from, and writing records <strong>to</strong>, a file sequentially. This<br />

class also belongs <strong>to</strong> the BankLibrary DLL, which means that it is located in the same<br />

project as is class FrmBankUI. (When students add class CRecord <strong>to</strong> the project containing<br />

FrmBankUI, they must remember <strong>to</strong> rebuild the project.)

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

Saved successfully!

Ooh no, something went wrong!