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.

Chapter 13 Graphical User Interfaces Concepts: Part 2 579<br />

heritance. As we discussed in Chapter 9, Friend access modifiers allow access only<br />

<strong>to</strong> other classes or modules belonging <strong>to</strong> the same assembly. In this example, Frm<strong>Visual</strong>Test<br />

does not belong <strong>to</strong> the assembly of FrmInheritance (<strong>Visual</strong>Form), so<br />

Frm<strong>Visual</strong>Test cannot modify the controls that it inherits from FrmInheritance.<br />

1 ' Fig. 13.41: <strong>Visual</strong>Test.vb<br />

2 ' A form that uses visual inheritance.<br />

3<br />

4 Public Class Frm<strong>Visual</strong>Test<br />

5 Inherits <strong>Visual</strong>Form.FrmInheritance<br />

6<br />

7 ' new but<strong>to</strong>n added <strong>to</strong> form<br />

8 Friend WithEvents cmd<strong>Program</strong> As But<strong>to</strong>n<br />

9<br />

10 ' <strong>Visual</strong> Studio .<strong>NET</strong> generated code<br />

11<br />

12 ' invoke when user clicks Learn the <strong>Program</strong> but<strong>to</strong>n<br />

13 Private Sub cmd<strong>Program</strong>_Click(ByVal sender As System.Object, _<br />

14 ByVal e As System.EventArgs) Handles cmd<strong>Program</strong>.Click<br />

15<br />

16 MessageBox.Show( _<br />

17 "This program was created by Deitel & Associates", _<br />

18 "Learn the <strong>Program</strong>", MessageBoxBut<strong>to</strong>ns.OK, _<br />

19 MessageBoxIcon.Information)<br />

20 End Sub ' cmd<strong>Program</strong>_Click<br />

21<br />

22 End Class ' Frm<strong>Visual</strong>Test<br />

Derived class<br />

cannot modify<br />

these controls.<br />

Derived class<br />

can modify<br />

this control.<br />

Fig. 13.41 Class Frm<strong>Visual</strong>Test, which inherits from class<br />

<strong>Visual</strong>Form.FrmInheritance, contains an additional but<strong>to</strong>n.

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

Saved successfully!

Ooh no, something went wrong!