130 likes | 272 Views
Forms. Form. The form (.frm) and project (.vbp) files are saved as ASCII text. The structure of a form consists of: The version number of the file format. A block of text containing the form description. A set of form attributes. The Basic code for the form. Form1 - 1 VERSION 5.00
E N D
Form • The form (.frm) and project (.vbp) files are saved as ASCII text. The structure of a form consists of: • The version number of the file format. • A block of text containing the form description. • A set of form attributes. • The Basic code for the form.
Form1 - 1 VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default End
Limitations Of a Single Project • Single project can contain up to 32,000 "identifiers" (any nonreserved keyword), which include, but are not limited to forms, controls, modules, variables, constants, procedures, functions, and objects. • Variable names in Visual Basic can be no longer than 255 characters, and the names of forms, controls, modules, and classes cannot be longer than 40 characters. • Visual Basic imposes no limit on the actual number of distinct objects in a project.
Parts of a form • These are called design forms • Title bar-displays form’s title • Control box-maximize,minimize,close buttons • Main area where all controls are placed is called client area. • Form is sorrounded by a border
Controls • Controls which enable the user to program to do things • Control is an object that can be drawn on a form object to enable user interaction with a application • Controls are associated with properties,methods and events. • Properties that define their behavior • An event is an action recognized by a control
Events can occur as a result of user actions, program code or triggered by the system • Methods are procedures that operate on the object or that object performs on data. • Methods cause an object to perform an action or task.(Ex setfocus) object . method(arg1,arg2,….) are optional
Classification • Three controls : standard /intrinsic, ActiveX, Insertable • Intrinsic controls: these are basic controls and available in every edition of VB(ToolBox) • ActiveX controls are placed in separate file as .VBX or .OCX extension (Listview, Treeview). TO use these controls the corresponding files must be included in the project • Insertable : Another application’s object from withinVB application Controls
Modules • Code can be classified in three: • Class • Form • Standard • Each module can contain: • Procedure • Function • Property • Declarations • Constants • Variable
Naming Conventions The names you give to forms and controls: • must begin with a letter. • must contain only letters, numbers, and the underscore character (_); punctuation characters and spaces are not allowed. • must be no longer than 40 characters.
Value of the control • All controls have a property that you can use to store or retrieve values just by referring to the control, without using the property name. This is called the value of the control . • This is the most important or most commonly used property of the control.
Form Control • Initialize event: When an instance of the form object is created • Load :form is loaded into the memory • Activate :when the form is displayed initially or when the user returns to the form • Deactivate: The form is hidden or move from one to another • QueryUnload :It determines how the unload was initiated • Unload: unloaded from the memory • Terminate :Form object is Destroyed
Properties & methods of a Form • ScaleMode :Distance measurement (twips) • Height, Scaleheight • width • top • left • load • show • unload • Hide • Move