Академический Документы
Профессиональный Документы
Культура Документы
3.1 Definition 3.2 Concept 3.3 GUI Development 3.4 Introduction to Menu, Toolbar, Toolbox and Code Window 3.5 Visual Development and EventDriven Programming 3.6 Working with Control 3.7 Controlling Control properties
3.1 Definition
No need to write numerous lines of code to describe the appearance and location of interface elements but simply drag and drop rebuilt objects into place on screen
BASIC language and now contains several VISUAL BASIC - evolved from the original
hundred statements, functions, and keywords, many of which relate directly to the Windows GUI.
3.2 Concept
o Visual Basic - is a Windows development language. Some familiarity with the Windows environment and knowing some fundamental differences between programming for Windows versus other environments is necessary o The concept covers:- windows, events, messages, objects, user interface, controls and application
3.2 Concept
o Events
o Events can occur through user actions such as a mouse click or a key press, through programmatic control, or even as a result of another window's actions o Example:
OBJECT - Control Button mouseover - TextBox - RadioButton EVENTS click, doubleclick, setfocus, lostfocus change
o Messages
o Each time an event occurs, it causes a message to be sent to the operating system. The system processes the message and broadcasts it to the other windows. Each window can then take the appropriate action based on its own instructions for dealing with that particular message (for example, repainting itself when it has been uncovered by another window)
3.2 Concept
o Objects
o A combination of code and data that can be treated as a unit o A piece of an application, like a control such as Command button, label, textbox or a form itself o An entire application can also be an object
3.2 Concept
o User Interface
o the junction between a user and a computer program o is a set of commands or menus through which a user communicates with a program o The user interface is one of the most important parts of any program because it determines how easily you can make the program do what you want o Graphical user interfaces (GUIs) that use windows, icons, and pop-up menus have become standard on personal computers o To users, the interface is the application but the real interface is actually the code that is executing behind the scenes
3.2 Concept
o Controls
o Controls are instances of objects that have been created. These controls provide functionality to the forms and enable the user to create events for the program to respond to
o Application
o An application is a completed program
Context Menu
Label CommandButton
3.4 Introduction to Menu, Toolbar, Toolbox and Code Window o Project Explorer Window
o Lists the forms and modules in your current project o A project is the collection of files you use to build an application
Project Name
View object Form module Form folder
3.4 Introduction to Menu, Toolbar, Toolbox and Code Window o Properties Window
o Lists the property settings for the selected form or control o A property is a characteristic of an object, such as size, caption, or color
3.4 Introduction to Menu, Toolbar, Toolbox and Code Window o Form Designer
o Serves as a window to customize to design the interface of an application o Add controls, graphics, and pictures to a form to create the look you want o Each form in an application has its own form designer window
3.4 Introduction to Menu, Toolbar, Toolbox and Code Window o Form Layout Window
o The Form Layout window allows to position the forms in an application using a small graphical representation of the screen
3.4 Introduction to Menu, Toolbar, Toolbox and Code Window o Code Window
o Allows to write the programming statement to execute certain action or events o Double click at any object to view the code window
A
B
C
D E F
H I
o One of Visual Basics most important and compelling features is a design approach known as the event-driven programming model o VB program focus on the events that user expect to take place while the program is running. For example, the user clicks a button, selects an option, chooses a menu command, highlights an item in a list, or types an entry into a text box; all of these are events that are formally defined and recognized in Visual Basic applications o Accordingly, a program contains blocks of code known as event procedures that will respond to the specific events
o Mouse event : A number of events can result from the users interaction with the mouse
o it occurs when a user presses the left mouse button while the mouse cursor is position over a control
o DoubleClick
o it occurs when a user presses the left mouse button twice in rapid succession, without moving the mouse, while the mouse cursor is position over a control
o DragDrop
o it occurs when a user presses and holds down the mouse button, drags one control over another, and then releases the mouse button
DragDrop
o MouseDown
o MouseUp
o MouseMove
o Keyboard Events : Keyboard events enable the application to monitor the keyboard input that is being passed to a program, and to modify that input if necessary. The main purpose of these events is input validation
o KeyPress
o it occurs when a key is pressed and released on the object that currently has the focus. If no object has the focus, the event is directed to the form o it occurs when a key is pressed o it occurs when a key is released
o KeyDown o KeyUp
o State-Change Events : State-Change Events perform certain actions when something starts or changes
o Activate
o it occurs when a form becomes the active window (usually by clicking on it)
o Deactivate
o it occurs when the user moves from one form to another
o GotFocus
o it occurs when an object becomes the one in focus, usually through a user action like clicking or tabbing
o Load
oIt occurs when a form is loaded
o Unload
oIt occurs when a form is being unloaded from the program by a user action like closing a Control menu or by using an Unload statement in code
o Miscellaneous Events : Another group of events exists to service very specific requirements
o Timer
o It occurs when a preset timer event elapses
o Scroll
o It occurs when a user drags the little box inside a scroll bar
o PathChange
o It occurs whenever the default path for file lookup changes. It applies to only the File list box
o One project file that keeps track of all the components (.vbp) o One file for each form (.frm) o Optionally, one file for each standard module (.bas) o One binary data file for each form containing data for properties of controls on the form (.frx). These files are not editable and are automatically generated for any .frm file that contains binary properties, such as Picture or Icon o Optionally, one file for each class module (.cls) o Optionally, one or more files containing ActiveX controls (.ocx) o Optionally, a single resource file (.res)
Events
o Exercise :
o Exercise :
o Exercise
o Exercise
o Create a frame on the form and create 3 check box on the frame o Change the appropriate properties with suitable values o Run the current project o Try to click inside the check box and examine the effect
o Exercise
o Create a frame on the form and create 3 option button on the frame o Change the appropriate properties with suitable values o Run the current project o Try to click inside the option button and examine the effect o Compare it with the check box created before
Left, Top : determine the coordinate of a control. By default, the placing of a control is set based in upper-left corner of a screen. Using this property, user can place the control wherever on the screen using programming code Enabled : by default, the value of this property is True which enables the control to accept user input. If the value is set to False, the control will be in gray colour and it cannot accept any user input Visible : show (True) and hide (False) control on the from
Important Notes
o Every control created on the form must has a unique name so that programmers can identify which control will be used in programming code o Each control should be named after what it is use to represent (information that the control hold). Eg. txtsalary : a text box that will hold user salary o Every control on the form has its own properties