Syntax: Syntax Error Refers To An Error in The Syntax of A Sequence

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 33

Errors are of three types: Syntax error, Run-time error and logic errors

Syntax: Syntax is a programming languages collection of grammar and


spelling rules.

Syntax Error: syntax error refers to an error in the syntax of a sequence


of characters or tokens that is intended to be written in a particular programming language. Syntax errors are those that appear while you

write code.
If there is syntax error the source code cannot compile. Example of Syntax Error : a)Illegal variable name e.g. As String) b)A == 7 Dim 6name AS String instead of (Dim name

Run-Time Errors: Run-time errors are those that appear only after
you compile and run your code. These involve code that may appear to be correct in that it has no syntax errors, but that will not execute.

Example of Run-Time errors:


a)File is missing or corrupted so cannot perform the OPEN function.

Logical Errors: Logic errors are those that appear once the
application is in use. They are most often unwanted or unexpected results in response to user actions. Logical error are hardest to find.

Example of Logical Errors:


1)Improper use of operator. E.g. use of * to add two numbers. 2)Improper use of conditional statements.

Source Code: In computer science, source code is any collection of


statements or declarations written in some human-readable computer programming language.

Compiler: compiler is a computer program (or set of programs) that


transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code/ Machine code).

Machine Code: Machine code or machine language is a system of


instructions and data executed directly by a computer's central processing unit. Machine code is in binary form, consists of 0s and 1s.

Two types of compile in visual basic.


Compile to P-Code: before Visual Basic version 5, the VB applications
are compiled to executables which contain P-Code (pseudo code) . The P-

Code is not the machine code thats why it is not directly understood by the
machine (Processor). To convert the P-code into machine code there is Visual basic runtime module. The runtime module file name is : VBRUNxxx.DLL or MSVBVMxx.DLL (VB 5 and higher)

Advantage of P-Code:
1. Easy to generate executables files. 2. Less overhead required in case there is change in language.

Disadvantage of P-Code:
1. Only suitable for small programs 2. Slow execution of program.

Compile to Native code: After VB version 5, the source code can be


directly compiled to native code (machine code) which can be understood directly by the processor.

Advantages:
1.Faster execution of programs 2.Suitable for large applications

Disadvantage:
1.Difficult to change compiler 2.More time required to create the executable files.

Visual Basic Application Modes:


1. Design Mode: when the application is being created. Form window,
code window, properties window etc are available to design the application.

2. Run Mode: when the application is executing and the user can interact
with the application.

3. Break / Suspend mode: when in between the run mode of


application the break button is pressed the application comes in to the Break mode. Stop statement also put the application in break mode.

Difference between end and stop statement:


The stop statement is similar to End statement, except it puts the program into break mode.

Private sub command1_click () Stop End End sub

Controls- The toolbar consists of collection of buttons called controls that represent object that we place on our form.

There is two types of controls


1.Standard / Intrinsic Controls: These are standard controls first
appear in the tool box window , when you create any application. e.g. text box, labels, command button, radio buttons etc. 21 standard

controls are available.

2. Custom Controls/User-defined controls: These controls are


added by including a special file that contains the control. Custom controls are contained in files with extension .VBX and .OCX.

Container Control: that can hold other controls within it e.g. Frame,
picture box ( it holds a picture) or form.

Child Controls: controls inside the Container Control are known as


child controls. If you delete container control then child controls are also deleted.

ActiveX Control: ActiveX is the name given to controls that you can
create. These controls have extension .OCX and you can add them to
your project.

Naming Conventions for Forms and Controls:


1. Must begin with a letter. 2. Must contain only letter, numbers and underscore 3. Must be no longer than 40 characters.

Control Form Command Button Text Box

Legal Names form1, Student_form okButton, cancelButton5 nameBox, ageBox

Illegal Names 5form1, student.form ok!button name:box

Grid: the grid is the dot pattern that comprise the form windows
background. The default size of each cell in the grid is 120*120 twips.

Twip: is a screen measurement. A twip is a resolution


independent measurement value. One twip is 1/1440 inch. (i.e. in one inch there are 1440 twips. Default unit of measurement in Visual basic is Twips.

Pixel : Pixel is device dependent measurement value.


In Visual Basic 6.0, the ScaleMode property could be used to change the coordinate system for a form or PictureBox control from the default scale of twips.

Control Name: FORM

Property
Minbutton & maxbutton Control Menu BorderStyle

Value
True / False

Description

True/ False 0-None, 1-Fixed Single, 2-Sizable etc. T/F Icon file T/F Image

If False, 3 buttons (min, max, close) get disabled Controls the border and resize of form. If value is 0 & 1, form cannot be resized. Whether form is active or not Describes the icon graphic image Form can move or not Form background picture.

Enable Icon Moveable Picture

Loading, showing and Hiding Forms.


A form can be any one state from three possible states.

1. Not loaded: Form lives on disk (HDD) and does not take any
resource.

2. Loaded and hidden: loaded in memory (RAM) and ready to


display.

3. Loaded and shown : form is shown and user can interact with it.

Four methods available for forms. 1. Load : to load the form in memory. E.g. load <formname> (load
form1).

2. Unload : to unload the form from memory and it also hides the form.
E.g. unload <formname> (unload form2)

3. Hide: to hide the form. E.g. <formname>.hide. 4. Show: shows the form and also loads the form in memory (if
unloaded). Syntax: <formname>.show[mode]

Value of Mode
1. 0 Modeless(default) : A modeless form allow the user to interact with other part of applications. 2. 1 Modal: Modal form take control over the application and does not allow user to interact with other parts of application.

Form Property Border Style MinButton , MaxButton and ControlBox Moveable

Value 1 False False

On Click on Show Form2 : Form 2 should be opened in Modal state and Form1 should be visible.

Command Button: allows users to click it to perform actions. Command


button also check pushed in and released state.

Property
Default

Value
T/F

Description
Button responds to an Enter Keypress even if another control has the focus. Button responds to an ESC key press even if another control has the focus.

Cancel

T/F

Enabled
Visible

T/F
T/F

Whether command button is active or not.

Tooltiptext Style

Text 0 and 1

Holds the text to display as tool tip To add back color or picture

Label: Display the text that user cannot directly change.

Property
Caption

Value
Text

Description

Alignment AutoSize WordWrap

Left, right, center T/F T/F

Alignment of caption. Default value is left Causes to expand horizontally and adjust to the size of its contents Become effective only Autosize is True. Then text is wrapped and expanded vertically

BorderStyle

Text Box: can be used to get input from user or to display the text. Features of Text Box.
1. You can insert and select text.
2. You can scroll the text if it doesnt fit in visible area. 3. Exchange text with other applications through the clipboard.

Property
Text

Value
Text

Description
Specify text to be displayed

Max Length MultiLine Scroll bar Password T/F 0,1,2,3 T/F

Maximum no of characters allowed. To allows mutiple lilnes in text box 0-none, 1- horizontal, 2-vertical, 3-both Specify any character in this property , then in place of text that character is displayed. Returns the selected text from text box Returns or sets the position of first character Returns or sets the length of the selected text

selText Selstart selLength

CheckBox: used for offering a small set of choices from which user can
choose one or more options.

Property
Caption

Value
Text

Description

Value Alignment Style

1 or 0 Left, right Standard / graphical

1 means check box is selected

0 means check box is not selected


Position of radio button either left or right to caption

Option Button: used to offer small set of options, unlike check boxes, they always work as part of group, selecting one option button immediately clears all other in group.

Frame Control is used to group Option buttons in Form.

Property
Caption

Value
text

Description
Display the text

Value Alignment

True or False Left, right

True for option button is selected False for option button not selected Position of radio button either left or right to caption

Frame Control: is used to group various controls. It is an container control. It does not carry out any job / action itself, id does not respond to any events by itself.

Property
Caption

Value
text

Description
Display the text

BorderStyle Apperance

0 or 1 Flat or 3d effect

0 for no border 1 for border

Private Sub Command1_Click() Dim amt As Integer If Check1.Value = 1 Then amt = amt + 300 End If If Check2.Value = 1 Then amt = amt + 250 End If If Check3.Value = 1 Then amt = amt + 50 End If If Option1.Value = True Then MsgBox ("your cash bill amount is "+ Str(amt)) Else MsgBox ("your credit bill amount is " + Str(amt)) End If End Sub

ListBox: list of choices appear to user. Choices are presented in one or more columns. Scroll bars appeared automatically if required.

Property
Multiselect

Value
0,1,2

Description
Whether multiple values can be selected or not. Cannot be changed at runtime. 0 means no multiple selection 1 means multiple selection through the click of mouse or spacebar 2 extended multiple selection. You can use shift or ctrl key plus mouse click to select items

Sorted Style List

True / False

Display the entries in sorted order

Multiple text

At design time you can add multple values from here and use ctrl+enter to go to new line

ComboBox Control: Similar to ListBox but takes less space on Screen. It is an expandable listbox which can grow when user want to select item.

Property

Value

Description

Style

0 (Default) , 1, 2

0 Drop Down Combo : user can select from the list and type a new one 1 Simple Combo: includes text box and list that doesnt drop down. To navigate through list use arrow keys. 2 DropDown list: drop down list is available user can select but cannot enter text.

Scroll Bar: is a long stripe with an indicator that lets the user select a value between the two ends of controls. Two types: 1. Horizontal scroll bar 2. Vertical scroll bar

Property
Min

Value
Number

Description
Scrollbar minimum value. Min value can be 0 Scrollbar maximum value. Max value can be 32767 Returns the current value of scroll bar

Max Value Large change Small Change

Number

Number Number

Change in value if user clicks on area other than indicator and arrow keys Change in value if user clicks at the arrow keys.

Image Control Box: Used to display the graphics. Formats that can be displayed ( .bmp, .dip, .jpeg, .gif, .cur etc) Important : image control responds to Click Events and can be used as a subsitute for command buttons, as item in toolbar.

Property
Picture

Value
Location of picture T/F

Description
Use this property to set the picture

Stretch

Determines whether image is resized to Image Control Box. IF True image is resized to the size of ImageControl Box. If False the Image control box is resized to the size of image.

Picture Box: used to display graphics, act as container for other controls and to display output from graphics methods or text using print method.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy