You are on page 1of 13

1.

What is Visual Basic (VB)? Visual Basic (VB) y y A tool that allows you to develop Windows (Graphic User Interface -GUI) applications. is the third-generation event-driven programming language and integrated development environment (IDE) from Microsoft for its COM programming model.

2.

What are the parts of Windows Visual GUI?

Sidedocks Sidedocks are side windows which can be placed at any border of a KCachegrind window. They always contain a list of cost entities sorted in some way. y y y The Function Profile is a list of functions showing inclusive and exclusive cost, call count, name and position of functions. Parts Overview Call Stack

View Area The view area, typically the right part of a KCachegrind main window, is made up of one (default) or more tabs, lined up either horizontally or vertically. Each tab holds different views of only one cost entity at a time. The name of this entity is given at the top of the tab. If there are multiple tabs, only one is active. The entity name in the active tab is shown in bold, and determines the active cost entity of the KCachegrind window. Areas of a Tab Each tab can hold up to four view areas, namely Top, Right, Left, and Bottom. Each area can hold multiple stacked views. The visible part of an area is selected by a tab bar. The tab bars of the top and right area are at the top; the tab bars of the left and bottom area are at the bottom. You can specify which kind of view should go into which area by using the tabs' context menus. Synchronized View with Selected Entity in a Tab Besides an active entity, each tab has a selected entity. As most view types show multiple entities with the active one somehow centered, you can change the selected item by navigating inside a view (by clicking with the mouse or using the keyboard). Typically, selected items are shown in a highlighted state. By changing the selected entity in one of the views of a tab, all other views highlight the new selected entity accordingly.

methods and event of visual basic?  Properties y Properties define the characteristics of an object such as Size. or restore the default layout set. for example. a selection change in one tab leads to an activation change in the next tab. This kind of linkage should. you can quickly switch between the old and the new layout via Ctrl+ and Ctrl+ .Synchronization between Tabs If there are multiple tabs. Color etc. Docked under the Project Explorer window Exposes the various characteristics of selected objects ² Other characteristics affect not just the appearance of the object but the way it . The set of layouts will be stored between KCachegrind sessions of the same profiled command. 3. After duplicating the current layout (View Layout Duplicate (Ctrl++)) and changing some sizes or moving a view to another area of a tab. What are the properties. be it right of the former or under it. allow for fast browsing in call graphs. Layouts The layout of all the tabs of a window can be saved (View Layout). or sometimes the way in which it behaves y y behaves too ² All these characteristics of an object are called its properties. You can make the current set of layouts the default one for new KCachegrind sessions.

drag the mouse. or double-click on an object. On the left-hand side of the window you can see the name of the object you are currently . y A method is a connected or built-in procedure. Writing Event Procedures In order to perform an action when a button is clicked on (for example) you will need to write VB code. Method y Method is an action that can be performed on objects. for example. Common Methods of Visual Basic Controls Method Use Move Drag Changes an object's position in response to a code request Handles the execution of a drag-and-drop operation by the user SetFocus Gives focus to the object specified in the method call ZOrder Determines the order in which multiple objects appear onscreen  Event An event is what happens when you. A method requires an object to provide them with a context. This code is entered through the Code Window. There are a large list of events that could happen within your application. You can then type the code associated with that object. you can choose the events that you want to respond to and then add programming code to tell VB what to do when that event occurs. click on a button. a block of code that can be invoked to impart some action on a particular object. You can see the Code Window by double-clicking on any control.

CLS filename extension) are the foundation of the object oriented programming in Visual Basic. So in the above example you would be writing code that will come into action when the form is loaded. there will be a horizontal line separating each procedure of code.working on (in this case the Form) and you can see the event that you are writing code for on the right (in this case you are looking at the Load procedure). when it is first displayed on the screen. Class Modules.(. y y 4. You write the code underneath the Private Sub statement and before the End Sub statement. Full Module View will show all of the code associated with that form/module in one long list. Enumerate and define the data types modules and operators in visual basic  MODULES ‡ Three kinds of modules: Form Modules. The procedure's name consists of the name of the object (in the above example it is the Form) followed by an underscore and then the name of the event (in the above case it is the Load event).a separate module containing a procedure is created that implements the common code. Procedure View only shows the code that is relevant to the current event that is being viewed.  OPERATORS IN VISUAL BASIC ARITHMETICAL OPERATORS y Operators + / \ * ^ Mod & Description Add Substract Divide Integer Division Multiply Exponent (power of) Remainder of division String concatenation Example 5+5 10-5 25/5 20\3 5*4 3^3 20 Mod 6 "George"&" "&"Bush" 10 5 5 6 20 27 2 "George Bush" Result y RELATIONAL OPERATORS Description Greater than Less than Greater than or equal to Example 10>8 10<8 20>=10 True False True Result Operators > < >= . In the bottom left hand corner of the code window there are two buttons: Full Module View and Procedure View.a single or simple application Standard Modules. The code you will write is called an Event Procedure. New objects can be created by writing code in class modules. for example.

form. These functions are procedures that return a value. data type conversion and built in functions Constants are named storage locations in memory. module or global scope and can be public or private as for variables. a constant can be declared and created.81 Data Type Conversion Visual Basic functions either to convert a string into an integer or vice versa and many more conversion functions. Conversion To Boolean Byte Currency Date Decimals Double Integer Long Single String Variant Error Function Cbool Cbyte Ccur Cdate Cdec CDbl Cint CLng CSng CStr Cvar CVErr A conversion function should always be placed at the right hand side of the calculation statement.<= <> = y Less than or equal to Not Equal to Equal to 10<=20 5<>4 5=7 True True False LOGICAL OPERATORS Operators Description OR Operation will be true if either of the operands is true AND Operation will be true only if both the operands are true 5. The Const statement is used to create a constant. A complete listing of all the conversion functions offered by Visual Basic is elucidated below. Identify the constants . Constants can be declared in local. . the value of which does not change during program Execution. The functions fall into the following basic categories that will be discussed in the follwing sections at length. When the user wants to use a value that never changes. Visual Basic Built-in Functions Many built-in functions are offered by Visual Basic fall under various categories. Constants can be declared as illustrated below. They remain the same throughout the program execution. Public Const gravity constant As Single = 9.

It must be unique within the same scope y Explicit Declaration  Declaring a variable tells Visual Basic to reserve space in memory. this field is incremented by 1 by the following statement Intcount = Intcount + 1  This calculation will result in intcount yielding a value of 1 as intcount would have been initialized to zero. Syntax Dim variable [As Type] For example. for example a variable by name intcount is used implicitly and is assigned to a value. The variables are declared with a Dim statement to name the variable and its type. it assigns the default variable type and value. The As type clause in the Dim statement allows to define the data type or object type of the variable. it is advisable to declare them explicitly. A variable name must begin with an alphabet letter and should not exceed 255 characters. Though this type of declaration is easier for the user. to have more control over the variables. Automatically whenever Visual Basic encounters a new variable.  In Visual Basic. This is because the intcount variable has been mityped as incont in the right hand side of the second variable. Date and Time Functions Format Function String Functions What are variables in visual basic? Variables are the memory locations which are used to store values temporarily. we can declare a variable by adding the following statement to the general declaration section of the Form. Dim strName As String Dim intCounter As Integer  Using Option Explicit statement  It may be convenient to declare variables implicitly. Say. to prevent errors of this nature.  Option Explicit . A defined naming strategy has to be followed while naming a variable. This is called implicit declaration. In the next step. It is not must that a variable should be declared before using it. But Visual Basic does not see this as a mistake and considers it to be new variable and therefore gives a wrong result.y y y 6. but it can lead to errors that may not be recognized at run time. This is called explicit declaration.

In case we need to keep track of the number of times a command button in an application is clicked.  Dim sum As Integer  The local variables exist as long as the procedure in which they are declared. the Static keyword is placed at the beginning of the procedure heading as given in the below statement. The value of a local variable can be preserved using the Static keyword. y y y Click Options item in the Tools menu Click the Editor tab in the Options dialog box Check Require Variable Declaration option and then click the OK button y Local Variables  A local variable is one that is declared inside a procedure. The values in a module-level and public variables are preserved for the lifetime of an application whereas local variables declared with Dim exist only while the procedure in which they are declared is still being executed. The Option Explicit statement checks in the module for usage of any undeclared variables and reports an error to the user. is executing. The follwoing procedure calculates the running total by adding new values to the previous values stored in the static variable value. . Variables that are declared with keyword Dim exist only as long as the procedure is being executed. Once a procedure is executed. a static counter variable has to be declared. This variable is only available to the code inside the procedure and can be declared using the Dim statements as given below. A static variable is declared as given below. and the procedure would return the same value with which it was called. The Option Explicit statement can be explicitly placed in the general declaration section of each module using the following steps. the previously accumulated values would not be preserved accross calls to the procedure. This forces the user to declare all the variables. y Static Variables  Static variables are not reinitialized each time Visual Invokes a procedure and therefore retains or preserves value even when a procedure ends. To make all variables in a procedure static. Function RunningTotal ( ) Static Accumulate Accumulate = Accumulate + num RunningTotal = Accumulate End Function  If the variable Accumulate was declared with Dim instead of static. the values of its local variables are lost and the memory used by these variables is freed and can be reclaimed.  Static in Permanent As Integer  Variables have a lifetime in addition to scope. These static variables are also ideal for making controls alternately visible or invisible. The user can thus rectify the error on seeing this error message.

In this case.. and this memory is released only when the form is completely unloaded from memory. (Public variables in BAS modules are global variables. a form module. even if they can be accessed only while Visual Basic is executing code in that module. the Counter starts with its default value of zero. Variables in form and class modules exist only when that module is loaded in memory. while a form is active (but not necessarily visible to the user) all its variables take some memory. these variables are useful for sharing data among procedures in the same module: ' In the declarative section of any module Private LoginTime As Date ' A private module-level variable Dim LoginPassword As String ' Another private module-level variable You can also use the Public attribute for module-level variables. for all module types except BAS modules. you're creating a strange beast: a Public module-level variable that can be accessed by all procedures in the module to share data and that also can be accessed from outside the module. The next time the form is re-created. Private Sub Command1_Click ( ) Static Counter As Integer Counter = Counter + 1 Print Counter End Sub The first time we click the CommandButton.Static Function RunningTotal ( ) Example The following is an example of an event procedure for a CommandButton that counts and displays the number of clicks made.) In this case. Visual Basic then adds 1 to it and prints the result. y Module Levele Variables  A module level variable is available to all the procedures in the module.. Such variables are visible only from within the module they belong to and can't be accessed from the outside. it's more appropriate to describe such a variable as a property: ' In the declarative section of Form1 module Public CustomerName As String ' A Public property You can access a module property as a regular variable from inside the module and as a custom property from the outside: ' From outside Form1 module. Private variables in standard BAS modules live for the entire life of the application. and so on³you're creating a private module-level variable. however.CustomerName = "John Smith" The lifetime of a module-level variable coincides with the lifetime of the module itself. In general. They are declared using the Public or the Private keyword. Visual Basic reallocates memory for all . In other words. a class module. Form1. If you declare a variable using a Private or a Dim statement in the declaration section of a module³a standard BAS module.

This is the interface for Visual Basic 2005 Express Edition. the All Windows Forms tab has entries named TextBox. You will use Microsoft Visual Basic 2005 Express Edition to build the user interface (the visible part that users interact with) by adding controls from the Toolbox to the form. Nothing for object variables). For example. "" for strings. it is named "WindowsApplication1". You will do this when creating any Visual Basic program. we can have a public variable named R and within a procedure we can declare a local variable R. and CheckBox that represent controls that you can add to your application by dragging them onto the form. What are the procedures in creating program in visual basic? Step 1: Create a Project in Visual Basic. and All Windows Forms. Inside each tab is a set of entries that represent controls or components that you can add to your application. y Public vs Local Variables  A variable can have the same name and different scope. References to the name R within the procedure would access the local variable and references to R outside the procedure would access the public variable 7. The Toolbox is on the left side of Visual Studio and consists of several tabs such as Data. If this is the first Windows Application project that you have created. To add controls to your application . 2. 1. Select Windows Application and click OK. Button. Components. A new form displays in the IDE. also known as the integrated development environment or IDE.variables and resets them to their default values (0 for numeric values. and the necessary files for your project are added to the Solution Explorer window. The New Project dialog box opens. On the File menu. Step 2: Create a User Interface It is now time to start building your Web browser. 3. click New Project. From the Windows Start menu. The "Welcome to Visual Basic Express" screen appears. Your first step in creating a Visual Basic program is to open Visual Studio and create a project. choose Microsoft Visual Basic 2005 Express Edition. For example.

Click the Toolbox panel. select the Panel control. it neither looks like nor functions as a finished application. however. The Toolbox opens. 5. drag a TextBox control and place it on top of the Panel. From the same tab. In this lesson.1. You can also resize controls by clicking and dragging the edge or corner of the control. Step 3: Customize Looks and Behavior In the previous lesson. drag a Button control and place it on top of the Panel. select a WebBrowser control and place it below the Panel. you may want to close it now to give yourself more room to work. from the All Windows Forms tab. Click the All Windows Forms tab of the Toolbox. Finally. You can do so by clicking the Auto Hide icon again. 2. . Tip If you have difficulty finding the correct control. you will set properties to control the appearance of your controls. using the Properties window. select the Panel control. Tip The Toolbox is easier to use if you keep the window open. To set the properties of your controls 1. right-click on the Toolbox and then select Sort Items Alphabetically. 4. At this point. Tip If you kept the Toolbox window open. 3. From the same tab. Tip You can reposition controls using a drag-and-drop operation. you created a user interface by adding controls to your application. . In the Form Designer. You can do this by clicking the Auto Hide icon. and then drag a panel onto the top-left corner of the form. which looks like a push pin.

select the Text property of the Button control. VB WebBrowser1. you will add the code that will control your program's functions. You can sort the properties alphabetically by clicking the AZ button in the Properties window. In the Properties window. set its Dock property to Fill by selecting the Dock property. In the Form Designer. type the following. In the Properties window. select the WebBrowser control.. In the Code Editor. you used the Properties window to configure the properties of the controls on your form. In the Form Designer. A new window called the Code Editor opens.Navigate(Textbox1. delete Button1 and replace it with Go!. 3. To add code and functionality to your program 1. Tip The Dock property is found under the Layout category. This is where you add all the code for your program. . double-click the Button control. and resize the form to suit your taste. 2. Resize or relocate any of the controls. 6. In this lesson. In the right-hand column. or you will not be able to see them when you run the application. A small property-selection window with several boxes is displayed. 7.The Properties window in the lower-right corner of the IDE displays all properties for the Panel control named Panel1. Step 4: Add Visual Basic Code In the previous lesson.Text) This code will run when users click the button. and then click the arrow to the right. 4. The Panel control expands to fill the top of the form. and selecting the center box in the property-selection window. 5. clicking the arrow to the right. Click the top box in the property-selection window to set the Dock property to Top. In the Properties window. select the Button control. 2. In the Form Designer. select the Dock property. Note The TextBox and Button controls must remain on top of the Panel.

Tip You can also end the program by clicking the Close button on the top-right corner of the form. the cursor is automatically located inside the Button's procedure . Step 5: Run and Test Your Program Now that your program is complete. 4. for this program.Tip When the Code Editor opens. testing can be a long and difficult process. all you need to do is run it! To run your program 1. . To close the program. In the text box. Connect your computer to the Internet. click Start Debugging. For complex programs. From there. which will be discussed in detail in a later lesson. on the Debug menu. 3.microsoft. it is time to run and test it. 2. This command runs your program. To visit another Web page. The WebBrowser control in your program navigates to the Microsoft home page. click Stop Debugging.com and click the Go! button. Tip A shortcut to run your program is to press F5.you can just start typing. you can navigate through any related links. type http://www. Happily. On the Debug menu of the Visual Basic IDE. type the address in the text box and click the Go! Button.

freetutes.htm#Heading1 http://visualbasic.References http://members.80%29.microsoft.80%29.com/en-US/library/eyzd6e34%28v=VS.aspx http://msdn.aspx Lectures from higher years :) .80%29.com/en-US/library/s878kxw0%28v=VS.com/acha_ean/vb6_se/ch06.aspx http://msdn.com/en-US/library/y7x894ky%28v=VS.html http://msdn.tripod.com/learn-vb6/lesson1.microsoft.com/learn-vb6/lesson6.microsoft.ehow.aspx http://msdn.microsoft.microsoft.asp http://visualbasic.html http://www.com/tips/visual-basic-procedures-functions.com/list_7593761_methods-visual-basic.80%29.html http://visualbasic.aspx http://msdn.2.1.com/learn-vb6/lesson2.1.com/en-US/library/s3hwe76s%28v=VS.virtualsplat.html http://www.com/en-US/library/bx0kecz4%28v=VS.freetutes.freetutes.80%29.