Professional Documents
Culture Documents
A program is a set of instructions that guide the computer in carrying out a specific task. To write a program you need to have a programming language (software) such as: Visual Basic, Turing, Basic, Java, Fortran, Cobol, C++, etc. These are English-like languages that humans can read, understand and write, however the computer can not understand these languages! In order for the computer to carry out the instructions, the program must be translated to a language the machine understands, called machine language and then executed. The programs we write in Visual Basic are first translated by the VB software. When the statements in the original or source program are translated to machine language, called the object program, the program is said to be compiled and ready for execution
Controls/Objects In VB, a program is started by drawing the user interface (the part of the program a user will see) on a form (the rectangular area with the grid marks in the center of the IDE). All the controls you can place on a form are in the toolbox, on the left side of the IDE. Controls you place on a form and the form itself are called objects. Examples of objects: form - a windows screen button label - user can not change during run time textBox - user can change during run time horizontal scroll bar pictureBox The Toolbox contains the following standard controls: Picture Box Label TextBox Button
2
GroupBox Check Box RadioButton ComboBox ListBox Horizontal Scroll Bar Vertical Scroll Bar Timer When placing several objects on a form, use the commands on the Format menu to place, size, and align the objects. First, drag the mouse around the objects to select them. Using the commands on the Format menu, you can then align or size the objects as necessary. Object properties can generally be set at either design time or run time Here is a form with Label, TextBox and Button objects.
Label Control
A label is a graphical control used to display text. The user cannot edit the text in a label. The most common use for a Label control is to identify controls that do not have a Caption property, such as the TextBox control. You can also use the Label control to display text such as status messages and other program information.
TextBox Control
You use a TextBox control to obtain information from the user or to display information provided by the application. Unlike information displayed in a label, the user can change information displayed in a text box. TextBox objects have a 'ReadOnly' property, that when set to 'true' does not allow the user to type into the textbox.
3
Button Control:
A Button performs a task when the user clicks the button. You use a Button control to begin, interrupt, or end a process. When clicked, a command button appears to be pushed in and so is sometimes called a push button. The most common event for a Button control is the Click event.
Properties
Properties define the appearance and behavior of objects. Text, Font, and Name are common examples of properties. Properties are the attributes you set or retrieve. Each object has a long list of properties. These properties are very important to making the screen look right and to making the program act right.
Methods
Methods are actions that an object is pre-programmed to perform, such as move, hide, show itself, etc. The Hide method, is an example of a method that does not have arguments. The following code makes the form frmGame disappear from view: e.g. frmGame.Hide In contrast, the FindString method, which finds a string in a ListBox requires the desired string to be found. The following code returns the location in the ListBox of the word 'school':
4
Events
Events are actions the user can perfom, which objects can be programmed to respond to, such as click, double-click, keypress etc. An event is an action recognized by an object. Clicking a mouse or pressing a key are examples of events. Some events include: Activate Change DragOver GotFocus Load LostFocus
Each object has its own set of events that it recognizes. The events listed do not apply to all objects. For example, a form can recognize either a Click or DblClick event while a button only recognizes a Click event.
References
http://www.doyle.wcdsb.ca/ics3mi/notes.html ask.com/visualbasicprogram