Tuesday, July 19, 2011

Mobile Phone Tricks


Code
last changes
Function/description/information
*# 06 #
16.12.03
Seriennummer/IMEI indicates (actually also a GSM is code - see further below)
*# 0000 #
16.12.03
SW version announcements (e.g. V3.42.1, 16-10-03, Nhl-10)
*# 2820 #
16.12.03
Bluetooth (BT) device address indicate.
xx #
16.12.03
Directory quick access (xx = storage location and afterwards lozenge e.g. 24 #)
A/from key
16.12.03
Short pressing for menu for switching between profiles
Menu key
16.12.03
Long pressing for "task manager" - switching between active programs (with "C" key programs can be terminated.)
Menu quick access
18.01.04
Over in the menu e.g. to point 3.1 arrive simply 31 enter (if the third symbol a file is opened is for these and then in it started the first Programm/Icon).
Autostart go around
28.12.03
When switching on of the Handys on to the pin inquiry the key "ABC" (pin) comes the whole time keeps pressed - this is to ignore (allegedly) the autoinitialization programs.
#
15.02.04
Do not switch between different lines (AS)... goes e.g. with Austrian ONE Handys (see nose cunning). I could not try out however also, since I did not have 2 lines on the SIM map.
12345
16.12.03
... is according to standard set the Nokia nokia-Sicherheitscode.
0000
16.12.03
... is according to standard those (with Vodafone windshield frame section) set 2te pin and that standard net code/password
With D1 the standard net code is the last 4 numbers of the card number without HLR e.g. 99999234-5/55 - > 2345
0 - for a long time press
25.10.04
If one the "0" in the main menue for a long time presses those homepage of the standard WAP connection is called.




Caution - starting from here the codes are "dangerous"
*#7370925538#
* # of res wallet #

28.12.03
... is to be deleted the code around the "wallet"! Input like normal telephone number (not in wallet code inquiry windows).
NOTE! Afterwards the "wallet" is empty, can again be put on however with new code.
*# 7780 #
17.01.04
The "original attitudes" and telephone re-establishes is again started (an appropriate inquiry and it follow before must the sicherheitscode be entered).
NOTE! Afterwards various "attitudes" are away - among other things these:
  • Points of entrance (Provider dependent points of entrance and attitudes)
  • Bluetooth attitudes
  • Favorite
  • Allocation of the two keys (beside Navi keys) in the main menue
  • Profiles are "neglected" (as with distribution) - still there however new bell tones, etc. are...
  • SMS/MMS/E Mail attitudes
  • Logos and spielstaende (allegedly) also deleted...
Programs, calendars and contacts, etc. not changed...
Also the sicherheitscode remains.
This putting back goes also via menu under "attitudes - general - original telephone once.".
*# 7370 #
21.01.04
Soft format: If the Handy (only telephone memory) formats, puts back the attitudes (see * to # 7780 #) and implements a software RESET. (however still another inquiry comes before.)
NOTE! If the Akku to 75% are loaded at least, Akku do not only accomplish during the procedure under any circumstances remove! The procedure takes some minutes (approx. 3-4), is absolutely waiting!
This is "only" a soft format... Hard format with "green, 3, *"... see below.
Green, * 3
21.01.04
Hard format: If the Handy (only telephone memory) formats, puts back the attitudes (see * to # 7780 #) and implements a RESET.
NOTE! If the Akku to 75% are loaded at least, Akku do not only accomplish during the procedure under any circumstances remove! The procedure takes some minutes (approx. 3-4), is absolutely waiting!

Proceeding: Equipment switch off, which keep "green key" (take off) at the same time pressed, "*" and to "3" key and switch the equipment on (the keys thereby keep further pressed)... to "Formatting" on the display appears...
If that does not function, then equipment for 1 hour switch off, Akku so for a long time rausnehmen and again try.
"only" virtual the memory is generally cleared - genuine formatting can take place only in a Nokia service center, if the Fash is deleted there and/or new L.G. is installed.
Mixed
16.12.03
* # 92702689 #, then switch - system menu off (goes with me not)

The following code do not fold (with me also):
* EFR0 # (* 3370 #) EFR activate (EFR = Enhanced Full rate Coding - language optimization)
# EFR0 # (# 3370 #) EFR switch off
* HRC # (* 4720 #) HRC switch on (HRC = helped rate Coding - language compression)
# HRC0 # (# 4720 #) HRC switch off
SIM LOCK
12.01.04
Simlock status query: (use "*" the key over "p,w" and "+" indications to enter)
# pw+ 1234567890 +1 # Provider LOCK status
# pw+ 1234567890 +2 # network LOCK status
# pw+ 1234567890 +3 # Country LOCK status
# pw+ 1234567890 +4 # Sim Card LOCK status

The code 1234567890 must be computed with a program e.g. SmartDCT4Calc and/or DCT 4 code Calculator from IMEI, etc.... Information look for if necessary here: www.gsm free.com or www.iphone forum.org

Info. to Simlock: SIM LOCK makes it for the offerer/network carriers possible, subsidized (verguenstigte) Handys to offer. Thus one makes oneself if necessary punishable if one SIM LOCK deactivated - in addition the warranty can purged. I take over for it no adhesion or responsibility!




GSM code
... should function at each Handy - however Netz(betreiber)abhaengig are... and "harmless"...
Generally applies: First enter code, "send" afterwards (< send green key > press) and one moment wait...
Good Links/Sites in addition: www.handy sms.de/forum/gsm codes.html or www.mobilemania.de/facts+infos/gsmcodes.php
SMS Tipps
27.01.04
To Tipps & cheat about SMS (with appropriate codes) are immediately in the FAQ list .
For example for the topic: SMS "retard" and/or deferred send, acknowledgment of receipt, reports...
Mark more simply
01.03.04
To Tipps & cheat to the topic "mark" e.g. with SMS entrance.
Over simply to mark simply the "pin" (ABC key) hold some e.g. SMS and move then Jostick downward.
Call number transmission
01.01.04
* 31 # - { CLIR - Calling LINE identification Restriction switches on for the general call number transmission }
# 31 # - switch off the general call number transmission
# 31 # [ telephone number ] - with the next call suppress the own call number (thus temporary)
* 31 # [ telephone number ] - with the next call transfer own call number (thus temporary)
* # 31 # - status query (of call number transmission)
# 31 * [ telephone number ] - own call number show, although receiving station switched call number suppression on. (is not usually de-energised of the Netz(betreiber).)

* 30 # - switch { TIE-clip - Calling LINE identification presentation for the announcement on of the call number of the caller }
# 30 # - switch off
* # 30 # - status query

This also partly goes with 6600 via Men: Attitudes - calls - own No. send...

The following codes are not supported by most Netz(betreibern):
* # 76 # - announcement of the call number, under which one reached the calling (not its call number during rufumleitung!) { COLP - COonnected LINE identification presentation }
* 76 # - switch on
# 76 # - switch off

* # 77 # - announcement of the call number, under which the caller reached me (not my call number during rufumleitung meinerseits!) { COLR - COnnected LINE identification Restriction }
* 77 # - switch on
# 76 # - switch off
Call bypasses (call Forwarding)
01.01.04
Bypass code (U):
U=21 always
U=61 retards
U=62 not attainable
U=67 occupies

U=61, 62, 67 can be parallel active

U=21 - > and then no more call signaling overwrites U=61,62 and 67!
Service code (D):
Not all nets support all services
D=10 language and fax (all calls)
D=11 only language
D=12 all data (speed/minutes)
D=13 only fax
D=14 DATEX j (active?)
D=15 teletex (active?)
D=16 only SMS
D=18 all data except SMS
D=19 all services except SMS
D=20 all services
D=21 all asynchronous services
D=22 all synchronous services
D=23 3.1 kHz GSM of language services
D=24 all synchronous POINT ton of POINT DATA inclusive. PADs
D=25 only data (all asynchronous POINT ton of POINT DATA inclusive. PADs)
D=26 DATA pack exchange on the left of inclusive. PADs
D=27 services thru PADs
D=29 12 Kbps digitally left

** U * [ goal call number ] * D # - bypass switch on
Input without * D means bypass of all services

## U ** D # - switch bypass off (individual bypasses and service code)
Without ** D all services are switched off to bypasses
## 002 # (all bypasses for all service codes switch off)
## 004 # (switch off only U=61, 62, 67 and for all service codes - thus ", not attainable, nonacceptance "occupies)

* # U ** D # - status of the bypasses query:
Input without ** D queries all services and bypasses

Bypass in the speaking and/or fax box: Number in bypass procedure with D=11 and/or 13 enter
Goal call number (e.g. D2-Netz: +49,172 xxx) and Handynummer without preselection (if necessary 172 replaces) enter.

Tap: During switched on rufumleitung "with occupied" being able "to reject" calls by one the red key during "to ring" presses. The caller is then passed on to the goal call number of the occupying bypass (e.g. mailbox).
Type for waiting period during rufumleitung 61: ** 61 * [ goal call number ] * 11 * [ time in sec. (5 to 30) ] #

This also partly goes with 6600 via menu: Attitudes - rufumleitungen -...
Knock/stops/parks/faults
01.01.04
Knocks is signaling a secondary call during a current discussion
* 43 # - switch on
# 43 # - switch off
* # 43 # - status query

This also partly goes with 6600 via menu: Attitudes - calls - knocking...

0 < sends > - reject while the discussion a knocking
1 < send > - discussion terminate, knocking discussion accept
certain discussion (y) terminate 1 (y) < send >
2 < sends > - discussion park, knocking discussion accept
certain discussion and new discussion leads 2 parks (y) < sends >

0 < sends > - caller the busy condition signal

This also partly goes with 6600 via menus existing during the discussion.
Call barrier
01.01.04
Possible only if bypass of the service code is switched off.
Check code (S):
S=33 all outgoing transmissions
S=331 outgoing abroad
S=332 outgoing abroad except home
S=35 all arriving transmissions
S=351 all arriving abroad

Special check codes (s) delete:
Switch off only in connection with the procedure
S=330 check code status outgoing & arriving transmissions switch off
S=333 check code status outgoing transmissions switch off
S=353 check code status arriving transmissions switch off
Service code (D):
Not all nets support all services
D=10 language and fax (all calls)
D=11 only language
D=12 all data (speed/minutes)
D=13 only fax
D=14 DATEX j (active?)
D=15 teletex (active?)
D=16 only SMS
D=18 all data except SMS
D=19 all services except SMS
D=20 all services
D=21 all asynchronous services
D=22 all synchronous services
D=23 3.1 kHz GSM of language services
D=24 all synchronous POINT ton of POINT DATA inclusive. PADs
D=25 only data (all asynchronous POINT ton of POINT DATA inclusive. PADs)
D=26 data packet exchange links incl. PADs
D=27 services thru PADs
D=29 12 Kbps digital link

* S * [Passwort] * D # - einschalten der Anruf-Sperre
# S * [Passwort] * D # - ausschalten der Anruf-Sperre
*# S # - Status der Anruf-Sperre abfragen

Passwort für Handy Sperre ändern:
** 03 ** [altes Passwort] * [neues Passwort] * [neues Passwort wiederholen] #
** 03 * 330 *[altes Passwort] * [neues Passwort] * [neues Passwort wiederholen] #

Dies geht beim 6600 auch teilweise via Menü: Einstellungen - Anrufsperre ...
PIN ändern
01.01.04
** 04 * [alte PIN] * [neue PIN] * [neue PIN wiederholen] #
** 042 * [alte PIN 2] * [neue PIN 2] * [neue PIN 2 wiederholen] #

PIN entsperren: ** 05 * [PUK] * [neue PIN] * [neue PIN wiederholen] #
PIN 2 entsperren: ** 052 * [PUK2] * [neue PIN 2] * [neue PIN 2 wiederholen] #

Dies geht beim 6600 auch teilweise via Menü: Einstellungen - Sicherheit - Telefon und SIM ...
Diverse Codes
02.02.04
Die folgenden Codes klappen nur in einigen (wenigen) Netzen/Netzbetreibern ... leider z.B. nicht im Vodafone D2 Netz (in Deutschland):
*#100# - Eigene Nummer (Own Number)
*#101# - HLR Nummer
*#102# - Switch Nummer
*#103# - Zeit im Netz (Network Time)
*#104# - Anrufbeantworter Nummer (Voice mailbox number)
*#105# - Switch number
*#147# - Letzter Anrufer (Last Caller)

#646# - Minutes Used: (646 spells 'MIN')
*#1345# or *174# - Vodafone Prepaid balance

*78 - Do not disturb - nur in Nord America in GSM und CDMA Netzen möglich
*79 - Cancel (s.o.)

Sunday, August 15, 2010


An introduction to Visual Basic

Microsoft Windows Operating is the world’s largest using computer operating system today. Because of its user friendly features and its ability to customize it became No 1.

Microsoft Visual studio is the programming solution is a power full tool for developing new packages under Windows platform.

Visual studio Provide many language under this package, Visual Basic was the simplest among them. Visual Basic as the extension of BASIC language, which was support only CUI interface (Like Command Mode, Disc Operating System).This interface has changed into a new interface called GUI. It has many advantages over CUI and allows users to develop smart applications using Text boxes, list boxes etc. Visual Basic is a powerful programming system that allows us to create application that fully makes use of facilities of Graphical User interface (GUI).

Visual Basic programming system is a window based productivity tool. It supports an event Driven programming model rather than conventional procedure oriented model. It provides a rapid application environment, a rich set of easy to use debugging tools.

How it works

In traditional applications, the application itself controls which portion of code execute and in what sequence. Execution starts with the first line of the code and follows a predefined path through the application, calling procedure as needed.

Visual Basic applications are event driven. In an event driven application, the code doesn’t follow a predefined path, it execute different code sections in response to events.

Events can be triggered by the user’s actions by messages from the system or other applications or event from the application itself. The sequence of these events determines the sequence in which the code executes, thus the path through the application’s code differs each time the program runs.

With most languages, if you make a mistake in composing your code the error is caught by the compiler when you start to compile your application. You must then find and fix the errors and begin the compile cycle again, repeating the process for each error you found. In Visual Basic VB interprets your code as enter it, catching and highlighting most syntax or spelling error on the fly. It much likes an expert’s eye over your shoulder as move through the codes.

In addition to this advanced error handling techniques, Visual Basic also partially compile the code as it is entered. When you are ready to rub the program, it takes only small amount of time to finish the compilation. If the compiler find s and error, it is highlighted and you can make correction and continue running the program, in short you need not go through the compilation cycle again.

Visual Basic IDE

Basic Features of Visual Basic

Visual Basic supports following features
  1. Data Access Features: this allows programmers to develop database front end applications and server side components for most popular database formats including MS SQL and other Databases.
  2. Active X Technologies: that allows programmers to use the functionality provided by other applications, such as MS Office [Word, Excel etc) and other windows applications. You can even automate applications and objects created using the professional or Enterprise editions of Visual Basic.
  3. Internet capabilities make it easy to provide access to documents and applications across internet server applications.
  4. Your finished application is a true executable (.exe) file that use a visual Basic Virtual Machine that you can freely distribute.

IDE Features of Visual Basic

Visual Basic posses a Integrated Development Environment [IDE] in which users can develop, run and debug their applications. Visual basic is a ‘front end’ which is used for design a screen [Called form] and also writing codes for the specific controls.

There are different type applications we can develop with visual basic enterprise edition. These types are referred as Projects; in visual basic we create projects which include different types of modules and many forms. A good project may have many forms as it can have. Following are the major type of projects we can have in Visual Basic

1. Standard Exe: A standard EXE project is a typical application in which we can use the database manipulation.

2. Active EXE, Active DLL: These types of project are available with the professional edition. Active X components are basic code building components that don’t have a visible interface and that can add special functionality to our applications.

3. Active X Control: Using this type of project we can create our own Visual Basic controls.

4. Active X Document EXE, Active X Document EXE: Active X Documents are in essence Visual Basic applications that can run in the environment of container that supports hyper linking, such as internet explorer.

5. Data Project: it is identical to the Standard EXE project type, but it automatically adds the controls that are used in accessing database to the tool box. Ti also adds the database Active X Designer to the project explorer window. Active X Designers are Visual tools for accessing and manipulating databases and generating reports.

6. DHTML Applications: Using this project user can be developing web pages that can be displayed in the browser’s window on the client computer.

7. IIS Applications: Visual Basic allows user to build application that run on the web server and interact with clients over the internet with the internet information server.

8. Add-in: We can create our own add-in for the VB IDE. Add-ins is the special commands we can add to Visual Basic menus. Add-ins helps us to extend the VB IDE.

New Project Dialog Box

VB IDE Windows and Components

From the New Project window we can select one type of project (We already mentioned different types of VB Projects we can create). The window have three tabs namely, New, Existing, Recent. The New Window Display the options to start New Project. The items in this window is Standard EXE, Active X EXE, Active X DLL , Active X Control, VB Application Wizard, AddIn, Active X Document EXE, Active X Document DLL. The next tab shows Options to open existing projects and the last tabs show help you to find recently worked project or the recent created programs.

By Selecting Our First Standard EXE Project we can move to the window as shown below. This is the main IDE window of Visual Basic. You can see the form in the design section, in which you can design your application by using the items of tool box.

Tool Box:

Items of tool box are used to design the application interface. These items are called as Controls. Controls are basically .OCX files. You can add additional controls to tool box using Project –Components or by Pressing Ctrl + T.

The tools box contains Label, Text box, Picture Box, Image, List Box, Combo Box, Option Button, Dir List Box etc. To place a control on the form first select the control with the help of mouse and move mouse over the form. When the mouse is on the form, the curser turned into a ‘+’ and we can draw the control on the form just as drawing a rectangle in MS Paint. The items of tools box arranged in ‘General’ Tab, you can re arrange controls in separate tabs by creating custom tabs by right click the Tool Box. Use Drag and drop to add the items to Tabs.

The default items available on the tools box are:

  1. Label: This control displays a text on the form that the user can’t edit. Labels are commonly used to identify the controls. The label box can be identified by a name by setting a name property (this can be done at design time only). The text in the label control can be change by changing the caption property.
  2. Text Box: This control displays the text that the user can edit.
  3. Frame: This control is used to draw boxes on the form and group other elements.
  4. Command button: The most common element of windows interface was command button. A command button represents an action that carries out when the user click the button.
  5. Check box control represents one or more choice that the user can select. One of the important property of ‘Check box’ control is ‘Value’. If the check box is marked it will be ‘1’ other wise it will be ‘0’.
  6. Option button: Option Buttons/Radio Buttons appears in a group, and the user can choose only one of them. It’s ‘Value’ Property will be True if it is selected. Other wise it will be false.
  7. List Box: This contains a list of options from which user can choose one more items. [In windows the Font List box is an example of the use of list box.]. The Selected item in a ListBox is given by the Text property the control meanwhile sorted property determines whether the items in the list box will be sorted or not.
  8. ComboBox: This control is similar to the ListBox, but it contains a Text/ Edit field. The user can either select an item from the list or enter a new string in Edit field. The item selected from the list given by the control’s TextProperty.
  9. Timer: When we need to perform tasks at regular interval we can make use of Timer. The main property of Timer Control is Interval, determines how often the timer notifies our application.
  10. Picture Box: This control is used to display images and images set with Picture property. The Picture Box control also supports few functionality of generating advanced drawing.
  11. Shape: This control is used to draw graphical elements such as boxes, and circles etc.
  12. Image: This one is similar to Picture Box but it support less functionality and make use of less resources.
  13. Line: Help use to draw a line.
  14. Data: Data Control provides point add click access to data stored in database [DBMS]. It was the simplest way to access Data Base.
  15. OLE: It is a window you can place on the Form to host documents from other applications. Through this control we can access the functionality of other applications within our application, if they support OLE feature.
  16. File System Controls: These are set of controls which help us to add file handling capabilities to out program. They are sued together to provide an interface for accessing and exploring drives, folders and files. The file system controls are as follows

1) Drive List Box: Used to display the drives on the system in a drop down list which the user can select.

2) Directory List Box: Used to Display all Folders in current Drive and lets the use move up and down through the hierarchy of the folders.

3) File List Box: This control displays a list of files in the current folder.

These are important controls even though there are plenty of controls used in VB. Lots to we will learn more about the property, in details.

Property Window

Properties are the attribute of controls. Every object has properties, for example a Pen, has its Color, Metal Type,

Ink Color, Type etc. In the same manner every control in VB has many properties. By using the property fields in property box we can change appearance, text / values displayed in the controls, the manner in which it look like etc. Some properties are read only, which means that they can to change at design time only, the values of such properties can’t change using code, while others are Read and Write. You can move Property window any side of VB IDE Window, can invoke using tool bar or by Pressing F4.

Project Explorer

Project explorer displays Opened project and other project components such as Classes and Modules. We can start multiple projects at the same time; you have to select the project you want to work with by selecting ‘Set as Start Up’. The project explorer has three Buttons on the Top of the window, namely View Object, View Code (F7), Toggle Folder. The first two used to move between Code Window and Form Designer. The third button helps you to change the listing style of Project Explorer. We can add Multiple Forms [SDI & MDI] and as many modules and classes we needed.

Form Layout

Form Layout Window is used to arrange the position of form while running the program.

Form Designer

The form designer is the main window in the middle of the screen, in which we can design and edit user interface. The same window displays a text editor in which we can enter and edit applications code. The form designer displays two windows, the form it self and the code window. Select the form you want to view in the project explorer, and then click one of two view buttons to see form or its code.

VB Editor/ Code Window

In Visual Basic, the editor is called code window, it is actually a turbo charged text editor with many productivity tool built in. we can open the code window by double clicking a form or control in the form. If we double click a form we will be taken into procedure for that control. Once the code window is open, we can go to any procedure for any object on the selected form.

Object Browser

Object browser allows us to browse through the Various Properties events and methods that are made available or exposed. We can access it by selecting object browser from the view menu or by pressing F2.

Declaring and using Variables

A variable is a name given to a location in Random Access Memory (RAM) where a data value is stored temporarily. The contents of the variable will lost when the program is ended, we can also alter values stored in a variable during life time of the program. Visual basic Variables can store string of Text, numbers, objects, Boolean values etc. for efficiency in sorting and using data visual basic provides a data type that store specific type of data.

Data Types and their Range

Data Types

Storage Size

Range of Variables

Byte

1 byte

0 to 255

Boolean

2 bytes

True or False

Integer

2 bytes

-32,769 to 32,767

Long

4 bytes

-2,147,488,648 to 2,147,488,647

Single

4 bytes

7 digits

Double

8 bytes

14 digits

Currency

8 bytes

4 decimal place

String

10 bytes

0 to approximately 2 billion

Object

4 bytes

Any object reference

Variant(With number)

16 bytes

Any numeric value up to a range of Doubles.

Syntax: - Dim As

Before we make use of variables we need to declare first, in general case. The naming convention is that, name of variables

· Begin with letter
· Can’t contain an embedded period or embedded type declaration character.
· Must not exceed 255 characters
· Must be unique with in the scope, which is the range from which the variable can
referenced a procedure, a form, so on

We can mix characters and numbers together. We make use of key words ‘DIM’ and ‘AS’ to declare a variable.

Visual Basic has two types of variable declarations

1) Explicit declaration and

*Place ‘Option explicit’ statement in the declaration section of a Form, Class, or

Modules

Option Explicit

This statement tells the compiler to check each variable before using it and to issue an error message if
we attempt to use a variable without declaring it.
To use variable without declaration, whose data type will be variant, just remove option explicit on from the General Section of Code Window and use or remove require variable declaration in the Tools->Option->Editor Dialog.

2) Implicit declaration.

In the first we use a statement to define the Data Type of the variable. The statement does not assign a value to the variable but merely tell visual basic what values it can contain.


Example: - Dim name As String

Variable declared without type is called implicit declaration. These are called variants, i.e. we can store any desired value in it.

Example: - Dim Str

Str =1001

Str =”GTEC”

Scope of Variables

Variables are not necessarily available through out the entire program. Their use can be localized to certain parts of the program only. Localizing in this variable is a part of good programming practice. The parts of program in which a variable can use is termed as ‘scope of the variable’. Global variable or Public variables can be declared in General section of the of the Form. Variable declared in the sub program or Functions are local (Private) to that Sub program or Function only.

Module Scope Variables

Visual Basic also has module scope variables which are declared in the general section of a Code Module. Module scope variables available through out all the procedure in that Module and not in other modules/Form (if you want to do so, you must use the keyword ‘Public’ to declare them).You can create module level variables by declaring them with the Private keyword in the declaration section at the top of the Module. They can be accessed by procedures and functions in that module.

Note: -You can’t declare public variables within a procedure, only within the Declaration section of a module.

Class Module Variables

There is another important variable concerning local variable, they only exist within the Class Module. Class module has limited access to the variable, they can only access by means of the object/ variables of that class.

Static Variables

In addition to scope, variables have life time, the period of time during which they retain their value. The values in module-level and public variables are preserved for the lifetime of your application. However, local variables declared with Dim exist only while the procedure in which they are declared is executing. Usually, when a procedure is finished executing, the values of its local variables are not preserved and the memory used by the local variables are not preserve and the memory used by the local variables is declared. The next time the procedure is executed; all its local variables are reinitialized.

However, you can preserve the value of a local variable by making the variable ‘static’. By using the ‘Static’ keyword to declare one or more variables inside a procedure, exactly as you would with the ‘Dim’ statement.

*Preserve values even when the procedure, using the Static Variable is ended.

Constants

Often you will find that your code contains a constant value that reappears over and over. Or you may find that code depends on certain number that are difficult to remember numbers that, in and of them have no oblivious meaning.

In this case, you can greatly improve the readability of your code and make it easier to maintain-by using constants. A constant is a meaning full name that takes the place of a number or string that does not change. Although a constant somewhat resembles a variable, you can’t modify a constant, or assign a new value to it as you can to a variable. There are two sources for constants.

1. Intrinsic Constants: which are provided by application and controls. Other application like MS Office also provides a list of constants you can use with their object, method, properties. Constants are also defined in the object library for each Active X Control.
2. Symbolic or User defined Constants: By make use of the keyword ‘Const’ you Can create constants of any type.
Eg: Const pa = 1233

Data Conversion

As we know variables are used to store manipulate data we handle with the pro program we build. There are occasions that we are convert data into another Data Type. Here is a list of inbuilt function to do the job.

Function

Convert An Expression to

Cbool

Boolean

Cbyte

Byte

Ccur

Currency

Cdate

Date

CDbl

Double

Cint

Integer

CLng

Long

CSng

Single

CStr

String

CVar

Variant

CVErr

Error

Special Values

Empty Value

If a variant variable has been declared , but has not yet been assigned a value is empty

Dim a=empty

Null Value

Null is commonly used in database applications to indicate that the fields does not contain data or that

an object variable has not been assigned a value.

Nothing

Nothing value is used with objects and indicate that an object variable has not been initialized.

Error Value

This is a peculiar value that allows right functions that return variant type or errors.

Operators in visual basic

  1. Logical Operators

Logical operators are use to join two or more relations. A logical expression returns True/False value.
A logical expression by AND returns a true value, if all the relational expression in the logical expression returns a true value, otherwise it returns a false value. In a logical expression by OR it returns a true value if any one or all of the relational expression returns a true value. If all the relational expression returns a false value the logical expression returns a false value.
The NOT operator is used for negation returns a true value while a<=b otherwise it is false.

Work with variables

Now we know different type of projects and how to variables and objects. Lets start our first variable projects.

Q) Read Principle Amount, Interest Rate, Term [Period] and calculate Interestamont and Net amount.

1. Start Standard EXE Project
2. Double Click the Form to reach the Code Window or press ‘F7’.
3. Then locate General Section from the Drop Down list box that appear top of the code window[Left Side]
4. Type the following code

Dim Amount As Integer
Dim Irate As Integer
Dim Term As Double
Dim Iamount
Dim Net
5. U can use comment section to Describe the code as follows in any part of the code window
This program calculate Simple Interest
6. Now we need to Read and manipulate the values. Add following codes to Click Event of Form, [Select the Click event from the Next list box from the Right side of the code window].

Private Sub Form_Click()

Net=0 ‘ Empty Values in Variables… (Initializing Zero Values to

Variables)

Iamount=0

Amount=InputBox (“Enter Principle Amount”,”Variable Test”)

Irate= InputBox (“Enter Interest Rate”,”Variable Test”)

Term= InputBox (“Enter Term/Period”,”Variable Test”)

Iamout=Irate*Amount/100*Term

Net=Iamount+Amount

Print “ Amount”,Iamout

Print “Net amount”, Net

End Sub

7. Now Ready to Test the project
8. Press F5 or Find Start Button from Tool Bar / Run Menu

*Here ‘InputBox’ is used to Input Values, it has two arguments first one is its message and second is Optional title, and i.e. u can avoid it. U can also leave the argument by inserting “ “.

*’Print’ is used to display values to Form.

Exercise:

1. Read Two Numbers and do Basic Calculations (+, -, *, /)?

* Remember First think of variables and their type, you need to create.

* If u has to display decimal points use Data Types like Double

2. Read a number and fin Cube(x3)?

3. Solve the equation (a+b)2?

Control structures in Visual Basic

A control structure allows you to control the flow of your program’s execution. If left unchecked by control-flow statements, a program’s logic will flow through statement from left to right and right to bottom. While some very simple programs can be written with only this unidirectional flow, and while some flow can be controlled by using operators to regulate precedence of operations, most of the power and utility of nay programming language comes from its ability to change statement order with structures and loops.

Decision Making Statements

Decision making statements useful when we need to evaluate particular conditions and divert the execution of the program in another path/flow.

VB support two decision making statements

If……Then...…else……End if

If…. Then..…else If…..End If

Select case…..…End Select

If……Then...…else……End if

Synax: If (Condition) Then

Else

<False Block Statements>

End if

If…. Then..…else If…..End If


Synax:

If (Condition) Then

Else If Then

Block Statements>

Else

End if


Select Case

Sintax:

Select Case(Expression)

Case :Value1

Statement1

Case :Value 2

Statement 2

.......................

.......................

Case Else

Statement

End Select.


The Select Case structure compares one expression to different values. The Select Case structure tests a single expression which is evaluated once at the top of the structure. The result of the test is then compare with several values and if it matches one of the corresponding block of statement is executed. The block of Case Else statement is optional and is executed non of of the previous Case Values match the expression.

Loop structures in VB

Loop structures are used to execute one or more lines of code repetitively. This will helpful when suppose we need to add values up to 100 to a list box. Loop structure also helps us to reduce size of the code. There are five loop structures available VB, they are
  1. While…Wend
  2. Do while …loop
  3. For…Next
  4. For Each…Next
  5. Do Until…Loop

While Wend

Syntax:

While (expression)

……………………….

……body of the loop...

……………………….

Wend

Do While

Syntax:

Do while (expression)

…………………………

…………………………

………body of the loop..

Loop

For …Next

Syntax:

For To Step Value

………………………………………………….

………………………………………………….

………………………………………………….

………………body of the loop………………..

…………………………………………………

Next

Do Until…loop

Syntax :

Do until ( expression)

……………………..

……………………..

..body of the loop….

…………………….

…………………….

Loop

Problem solving with Loops

Q1. Write a program to find average of first 10 nos?

Dim i,a,s As Integer

i=1

a=0

While (i<=10)

s=s+i

i=i+1

Wend

a=s/i

Print “Average” & a

Q2. Program to find factorial of a No.?

Dim n, i , f As Integer

n=Inputbox(“Enter a no”)

i=1

f=1

While (i<=n)

f=f * i

i=i + 1

Wend

Print “Factorial” & f

Q4. Program to find sum of digits?

Dim n,r,s As Integr

n=Inputbox(“Eneter a No”)

r=0

s=0

While (n>0)

r=n Mod 10

s=s+r

n=n\10

Wend

Print “Sum of Digitz=” & s

Q5. Program to check whether an input number is palindrome or not?

Dim n,r,m,temp As integer

n=InputBox(“Enter a no”)

r=0

m=0

temp=n

While(n>0)

r=n Mod 10

m=m*10+r

n=n\10

Wend

If temp=m Then

Print “Palindrome”

Else

Print “Not Palindrome”

End If

Q3.Program to print Palindrom no up to 50

Dim n,r,m,t,i As Integer

i=11

While (i<500

r=0

m=0
t=i

While (t>0)

r=t Mod 10

m=m*10+r

t=t\10

Wend

If (m=i) Then

Print i

End If

i=i+1

Wend

Procedures

With the help of procedure we can split our code into serveral small बिल्डिंग block s, which help the programmer to debug and maintain the program easily, these small बिल्डिंग ब्लाक इस काल्लेद अस प्रोसदुरे.
In visual basic there are Three Type of Procedures, they are
  1. Sub Procedure
  2. Function Procedure
  3. Property Procedure

  1. Sub Procedure
Event Procedure
Event procedure is an type of the Sub procedure. Event procedure was the very heart of the EOP programming. VB6 IDE generate the event procedure for the programmer. It is very easy to identify a sub procedure it has key words like End Sub,Sub.
The advantage of procedure is that we can reuse them wherever they are required.
A procedure never return value
A procedure can take arguments
User defined Procedure[SUB PROCEDURE]
We can create our own event procedure and make use of them and thus we can reduce the size the program in an extend.
Syntax:
[Visibility Mode] Sub Procedure Name (arg 1,arg 2..............arg n)
Function Body
End Sub
Where to Define?
We can define our procedure in Form module , Module and Classes.
How and where can call our procedure?
We can call and make use of procedure using the keyword Call, a general procedure can be called only with in another General procedure.
The following example illustrate this
Sub Sq_r(x As Integer)
Print "Squire of " & x & " Is:" & x*x
End Sub
Note: By default the Visibility Mode will be Public
Now it is the Time to Call the above Created Procedure
Private Sum Command1_Click( )
Call Sq_r(456)
Dim x As Integer
x=98
Call Sq_r(x)
' We can call as mush time we wish to have.
End Sub

Function Procedures

Function return a value, while procedure not.

Sysntax:

Visibility mode Function <Function Name>(arg lisit)As Return Type

Funtion Name=Return Value

End Function

Following example will illustrate the working of User defined function.

Function Rev(x As Integer)As Integer

Dim r,m As Integer

M=0

While x>0

R=m mod 10

M=m*10+r

X=x\10

Wend

Rev=m

End Function

Calling of Function

We can call Function in two ways

With the help of output statement like Print Rec(78)

The second method is that we have a variable which matching the return type of the Function.

Dim t As Integer

T=Rev(123)

We can also use function in calculation like this t=Rev(123)+Rev(345)


Module and Class Module

VB 6 provide two types special modules namely standard module and class module. Both of them don't have an visible interface, or a design form.

Event driven programming under Windows Platform

As we know, Visual Basic is a vent driven programming language. Program responds to specific action known as Events. An Event is any action performing by using any of input devices, primarily mouse ad keyboard. When we click on specific buttons and menus, action was fired.

For the easy handling of these events, Visual Basic uses events procedures.(Later we will discuss about different type of procedures) Visual Basic System creates event procedures. We can add code/commands that are meant to execute.

“Envent Driven programming carries many advantages over conventional programming techniques. The first one is its ease of use and manipulates data in many ways.”

For the best practice of event programming, we need to understand some basic events.

Form is the container of other controls that are available in the Tool Box

Lets check out few of the important events of Form

1. Load….Load event occure when for loaded to the screen.

2. Click….Event occures when user click on the form

3. Activate…. This event occure when we make use of the form

4. Initialize….. is triggered just before Load Event

Comments/Documentation

Comments are the none executable sections of the programm. We can use this facility to add descriptions of code or block specific areas of the code.

We can use a (Single quote) to comment a section of the code. It can be appeared any place on the code window, no matter it is within the Event procedure or within General Section.

For example:

Private Sub Form1_Click ()

‘Display a String to Text Box Control

Text1.Tex = ”Welcome to Knol”

End sub

Understanding and creating Visual Basic Project.

Under Visual Basic, we are creating programes as a project. Aproject has many components like Forms, Resource Files, Modules and Class Modules. These components can be seen on Project Explorer. The extension of the Visual Basic Project file is .vbp.

Design following Program using the Text Box Control, Label and Command Button.


Now lets add following code in the OK button's Click event.This will calculate the total

Private Sub OkBtn_Click()

Text3.Text=Val(Text1.Text)*Val(Text2.Text)

End Sub

In a Text Box Control all data you entered is treated as string. So that we use function Val() to convert it to Integer Value.
*The Text property of Text Box return/bring the input text.


In the Clear Button's Click Event we need yo add necessary codes to clear the Boxes.

Private Sub OkBtn_Click()
'*************************************
' Sample Documentation
' This Section Clear the Field
' ************************************


Text1.Text=""
Text3.Text=""
Text3.Text=""

End Sub

Now You are ready to test your first project. Press F5


Remember we can programmed same thing in different ways as the programmer wish to do things.

1 Build a Simple Image Viewer

To Build a Simple Image Viewer Program we need a Image,Drive List,Directory List,File List,Label and List Controls.
Image and Picture Controls area common in nature. Both of them have Picture property which is used to load picture to the control.In Picture control you can see that the picture is appeared in its actual size at the same time the Image control lets wrap it to the control with help of Stretch Property, Image also support some additional drawing functions.. Both the controls have a methods called LoadPicture which help us to load a specific file, all we have to do is specify the path of that picture to be shown.

Label: Label control is used to display a text. It can't be used to input value.It's main property is Caption, which display text given.

Drive List,Directory List,File List : These Controls work as a batch, i.e, they are meant to work together.
Frame Control is use to group controls, so that we can move them together.We change the caption property
to "Select a File".
Arrange these controls as shown below.

  1. Now Set Stretch property of Image box to True.
  2. Add a label control just above the File List control and set it's caption as "File Type"
  3. Add codes to show Directories and files in selected file and folders.

Const Title = "Picture Viewer 1.1" ' Create a constant called Title.

Private Sub Drive1_Change()
On Error GoTo Error1:
Dir1.Path = Drive1 ' Display all directories in Selected Drives.
Exit Sub
Error1:
MsgBox "Device Not Found"
End Sub

Private Sub Dir1_Change()

File1.Path = Dir1.Path ' Displays files in the Selected Folders
End Sub

Private Sub File1_Click()
Image1.Picture = LoadPicture(File1.Path & "\" & File1.FileName)
Form1.Caption = Title & "/" & File1.Name
End Sub

Private Sub Form_Load()
List1.AddItem "*.bmp"
List1.AddItem "*.jpg"
List1.AddItem "*.gif"
End Sub

Private Sub List1_Click()
File1.Pattern = List1.Text
End Sub

Now you are ready to test your application. You can change the icon of the form.

2 Creating a calculator

*Understanding control array.
In Visual Basic, we can use copies of one control instance, and they act as a group, They are also called as 'Control array'. Let us build calculator. First up all we need 9 buttons for showing the Digits (0-9).
  1. Insert a button and size it and copy the control and paste, when the system prompt for Yes or No, Click on the Yes button.
  2. Next we need 4 more buttons(array of controls) for Operation handling(Such as +,-,x,/),

Insert a button and copy paste, 3 times.

  1. Last, we need four more buttons (not array/copy) for “=”, ON, OFF, CE functionality and add a text box.

Now you are ready for coding.

Declare variables first in the General section.

Dim x, y As Integer

Dim optr As String

  1. Add following codes in the Click Event of CommandButton 1 (code window). Hit F7 to invoke the code window.

Private Sub Command1_Click(index As Integer)

'These codes take necessary action to display the inserted value into the Text box. Since the Buttons are 'array, we only need a single line of code.

Text1.Text = Text1.Text & index

End Sub


This section store information regarding the operations required by the user and it store details as a string to variable 'optr', so that we can make use of it in the next section.

Private Sub Command2_Click(index As Integer)

Select Case (index)

Case 0

optr = "+"

Case 1

optr = "-"

Case 2

optr = "*"

Case 3

optr = "/"

End Select

'Store value into variables and clear the text box.

x = Val(Text1.Text)

Text1.Text = ""

End Sub

Now we are ready for the operations.All we need is to check optr variable put necessary operation and set the out put to the text box. Add following codes to the equalto(=) button's Click Event.

Private Sub Command3_Click()

y = Val(Text1.Text)

Select Case (optr)

Case "+"

z = x + y

Case "-"

z = x - y

Case "*"

z = x * y

Case "/"

z = x / y

End Select

Text1.Text = z

End Sub

The following code


add ON & OFF functionality to the program. All we need is to disable and enable controls, we are using. For this purpose we used the loop structure since we are using two control arrays it become simple.


Private Sub Command4_Click()

This section ON the calculator.

For i = 0 To Command1.UBound

Command1.Item(i).Enabled = True

Next i

For i = 0 To Command2.UBound

Command2.Item(i).Enabled = True

Next

Command3.Enabled = True

Text1.Enabled = True

End Sub


Now you are ready to run your Calculator.

Note:

1. You can change your Programs icon and caption as you like.

2. Making your project a complete stand alone application require one more step.

Go to File->Make and enter name for it. Now the application is a stand alone

calculator, which means that it doesn't need VB to run the application.

3. Create a thumb nail viewer of images.(Understanding control array )

As we already learned control array is the copy of a control. Here we are going to experiment with the File system controls and image box as control array.

  1. First we need to Draw Drive List box, Directory List box and file list box
  2. Set the File List Box’s Pattern property as “*.jpg” to avoid accidental loading of files
  3. Add an image box and copy paste the box 29 time or as much you need
  4. Add a list box control, in which we are going to add different picture file types/ extensions and a command button
  5. Add following codes to Drive list box , Directory list boxes.
  6. Set Visible property of File1 to False(Hide it)

Private Sub Dir1_Change()

File1.Path = Dir1.Path

End Sub

Private Sub Drive1_Change()

On Error GoTo tt:

Dir1.Path = Drive1

Exit Sub

tt:

MsgBox "The divice cannot acces"

End Sub

7 .Add following codes to form’s load event.

Private Sub Form_Load()

List1.AddItem "*.jpg"

List1.AddItem "*.bmp"

List1.AddItem "*gif"

Drive1 = "E:\" ‘set initial drive

Dir1.Path = "unni" ‘ set initial directory

Image1.Stretch = True ‘resize the picture for image box.

End Sub