Types of Objects: Visual Basic is comprised of three fundamental object types called forms, controls, and modules, with the following definitions:
1。Forms are the same as windows。 A form is a class in the sense that you can have more than one instance of the same form。 Forms have properties, methods, and events。 A few examples are listed below:
546
Properties: Name, WindowState (normal, maximized, minimized), FillColor
Methods: Show, Hide, Move
Events: Click, Paint, MouseMove, Load
2。Controls are objects that are placed on forms, such as Command Buttons, Combo Boxes, Text Boxes, and Menus。 Although you can create custom controls, the standard controls that come with Visual Basic and the controls that are available through third-party vendors are generally sufficient。 The properties, methods, and events vary by the type of control。 A few examples include the following:
Properties: Name, Height, Width, FontName, Visible, BackColor, Style
Methods: SetFocus, Move, Addltem, Refresh
Events: Click, KeyPress, MouseMove, GotFocus, LostFocus
3。Unlike forms and controls that have predefined properties, methods, and events, code Modules are simply a repository for Visual Basic code。 Each code module has a declaration section and a code section。 Properties are defined in the declaration section。 Methods and events are defined in the code section with subroutines and functions。 Subroutines and functions can be defined as public or private。 Private routines are only visible to other routines in the same code module。
Writing Visual Basic Code: There are generally four steps to writing a Visual Basic program:
l 。 Draw a form (window)。
2。Draw controls (buttons, combo-boxes, text-boxes, etc。) on the form。
3。Customize the properties of the controls。 For example, specify a caption for a command button。
4。Write the code for the associated events and create code modules as needed。
III。 Object-Based programming with Visual
Booch calls the conceptual framework for the object-oriented programming style the object model。 In order for a model to be object-oriented, he says it must have the major elements of abstraction, encapsulation, modularity, and hierarchy (inheritance)。 He also says that the minor elements of typing, concurrency, and persistence are useful, but not essential。 We will describe the capabilities and limitations of Visual Basic in terms of the elements of Booch’s object model [Booch 94]。 We begin with the four major elements。
Abstraction: Abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provides crisply defined conceptual boundaries, relative to
the perspective of the viewer [Booch 94)。 A good abstraction is one that emphasizes the details that are important to the reader or user and suppresses details that are not [Shaw 84]。 Visual Basic is capable of representing abstractions quite well。 An object can be built in such a way that its interface provides its essential behavior, and nothing more。
Encapsulation: Abstraction and encapsulation are complementary concepts。 Abstraction defines the objects interface or the external view。 Encapsulation hides the implementation of the object from the outside view。 Booch defines encapsulation as "the process of hiding all of the details of an object that do not contribute to its essential characteristics“ [Booch 94]。 基于对象的编程评估英文文献和中文翻译(2):http://www.youerw.com/fanyi/lunwen_96426.html