Statistics Hand written
Statistics Hand written
INTRODUCTION
Data Access Features : Data access features allow to create databases and front –end
applications for most popular database format including MS-Access , SQL server , etc
Debugging: Visual Basic offers two different options for code debugging:- Debugging
Managed Code and Runtime Debugger The Debugging Managed Code individually
debugs C and C++ applications and Visual Basic Windows applications. The Runtime
Debugger helps to find and fix bugs in programs at runtime.
Exe File : We finished applications is a true .exe file that uses a run-time dynamic link
library (DLL) that can freely distribute.
Right on top we see “Project1 – Microsoft Visual Basic [design]. This is the
title of the project we are working on. The title is displayed on the title bar.
1. Double Click the desired control on the Tool box. That control will appear at
the center of the form.
2. Now we can drag the control and place it at a location of choice.
3. Click anywhere on it and press F4 or select properties window from view
menu or click right mouse button on controls and select properties from
pop-up menu.
4. We can change the caption and name in the properties window.
Example
Private Sub cmd1_click()
Text3.text = val(text1.text) + val (text2.text)
End Sub
Then the code in the click event procedure gets executed. The code instructs to
print a text on the form. After that we see a text printed on the form. This is the
concept of event driven programming. That means , the code is not executed from top
to bottom but it works when the corresponding event procedure is invoked.
MENU BAR
The Menu bar displays the commands that are required to build applications.
The main menu items have sub menu items that can be chosen when needed.
Below the Title Bar is the Menu Bar. The Menu bar has the following Menu…
File Menu : To open and save a new or existing project, to print project file.
Edit Menu : For all editing requirement Cut , Paste , Find , Undo , etc.
View Menu : To view the various part of visual basic project
Project Menu : Inserting and removing forms.
Format Menu : For spacing , placing and appearance of controls in form.
Debug Menu : To remove the errors that have crept in
Run Menu : To compile , start and stop the program.
Add-Ins Menu : To add tools like Data Manager , other wizard , etc
Help Menu : For On line help that every programmer needs to refer to
Pointer :
The Pointer provides a way to move and resize the controls and forms
TOOL BAR
Tool bar is a collection of buttons , it provide quick access to commonly used
commands in the programming environment.
We can click a button on the tool bar once to carry out the action represented
that button.
PROJECT EXPLORER
The Project explorer is located on the right side of the screen, just under the
Tool bar
It serves as a quick references to the various element of a project namely form,
Classes , and Modules. All of the objects that make up the applications are
packed in a project.
The Project explorer has three icons on its tool bar
o To View the Code
PROPERTIES WINDOW
The Properties window is docked under the Project Explorer Window.
This window lists all the properties for an object or control used in Visual basic.
Currently the only object is the form1.
Each and every form in an application is considered an Object. Now, each
object in visual basic has characteristics such as size and color.
A description pane that shows the name of the selected property and a short
description of it.
FORMS
The Form is one of the most basic objects in which the applications is developed.
The controls have to be placed on the form. A form is a window that contains
applications code and has other objects placed on it to create the User Interface.
Every form object has its own properties , events and methods associated with
it.
Anatomy of a form
The Form is the central figure in the IDE. Its has a title bar that contains the title
on the top left – hand corner, Form1.
There is also icon next to the title. On the top right hand side we will see the
Minimize , Maximize and Close buttons.
Graphic Methods
There are other properties for drawing lines , Circle , clearing the form for any
drawing object
Circle : To draw a circles
Line : To draw a Lines
Pset : To draw a point with a given color at a given location
Point : returns the color of screen at the given location
Show Methods
The Show method of a form displays that form on the screen. The Show
method is typically used to transfer control from one form to another.
Syntax:
Formname.Show
Example:
Form1.show
Using Load Statement
The Load statement is used to load a form or control into memory but
does not display it.
Example
Load form1.
Hide Methods
Example
Form1.Hide
Using Unload Statement
The Unload statement removes the from form the display and release its
memory.
Example
Unload Form1
CONTROLS
Controls are used to place on a form at design time thereby creating the User
Inter face area. There are 21 controls in General Tool box. Additional controls can be
included in the toolbox by using Components Menu item on the project Menu.
The four handles on the four corners are increase are to decrease the length and
breadth of the control
The two sizing handles on the horizontal edges are used to increases or
decreases the height on the control.
The two sizing handles on the vertical edges are used to increases or decreases
the Width on the control.
To move a control to another location , click on the control , hold down the left
mouse button and drag the control to location of choice.
Sometimes one control will overlap another control and likely to spend a great
deal of time looking for it. If the currently visible control is hiding another
control , this option will get enabled.
Select the Command Button and click on format on the Menu Bar
Declaring Variables
Variables in VB are declared using the DIM statement.
Syntax
Dim VariableName As DataType
Example
Dim mark as Integer
DATATYPES
Variable have a name and a data type. The data type of variable determines
how the bits / bytes representing those values are stored in the computer
memory.
All Variables have a data type that determine what kind data they can store.
Example : 1
Dim Varvalue As Variant
Varvalue = 23434
Example : 2
Dim Varvalue “ Variant by default”
Varvalue = “100” “ Varvalue contains “100” ( a string )
Varvalue = varvalue – 70 “ Varvalue now contains the numeric value 30
SCOPE OF A VARIABLE
Scope of a variable determines which part of the code can access the
variable. A variable is declared in general declaration section of a module to make it
available to all the procedures in the module.
There are different ways to declare the Variable
Local Variables
Static Variable
Module Level variable
Local Variables
Local variable is one that is declared inside the procedure. This variable is only
available to the code inside the procedure and can be declared using Dim Statement.
Example
Dim mark As Integer
Dim name As String
Static Variables
A static variable continues to exist and retains its most recent value. The next
time code calls the procedure, the variable is not reinitialized, and it still holds the
latest value that assigned to it.
Example
Static mark As Integer
Module Level Variables
Module level variable is accessible from all the procedures in the module but
not from other modules.
ARRAYS
Array is a set of similar items. All items in an array have the same name and
are identified by an Index.
Syntax
Dim Varname [([Subscripts])] as [New]type [,varname…]
Example Program
Dim studentName(10) As String
Dim num As Integer
Private Sub addName()
For num = 1 To 10
studentName(num) = InputBox("Enter the student name", "Enter Name")
If studentName(num) <> "" Then
Form1.Print studentName(num)
Else
End
End If
Next
End Sub
Private Sub Command1_Click()
addName
End Sub
Example
1. Dim Marks (50 , 50 ) As Integer
2. Dim Marks ( 101 To 200, 1 To 100)
3. Dim Details( 101 To 200, 1 To 100, 1 To 100)
Dynamic Array
Dynamic arrays differ from fixed arrays because a subscript range for the array
elements is not specified when the array is dimensioned.
A dynamic array can be resized at any time.
The subscript range is set using the ReDim statement
1. Declare the array with a Public statement or Dim statement at the module level
or a Static or Dim statement in a procedure
Dim DynArray()
Example
Months = 12
Dep = 6
Example