Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Visual Basic

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

1.What is Visual Basic Programming? What are its Advantages and Disadvantages ? Ans.

Visual Basic is a high level programming language which evolved from the earlier DOS version called
BASIC (Beginners' All- purpose Symbolic Instruction Code). However, people prefer to use Microsoft Visual Basic today, as it is a well-developed programming language and supporting resources
are available everywhere. Visual Basic is easy to learn Programming language. With Visual Basic we can develop Windows based applications and games. Visual Basic is much easier to learn than
other language (like Visual C++), and yet it's powerful programming language. .Advantages of VB :-(1) The structure of the Basic programming language is very simple, particularly as to the
executable code. (ii) VB is not only a language but primarily an integrated ,Interactive Development Environment ("IDE").(iii) The VB-IDE has been highly optimized to support Rapid Application
Development ("RAD"). It is particularly easy to Develop Graphical User Interfaces and to connect them to handler functions provided by the application. (iv) The graphical user interface of the VB-
IDE provides intuitively appealing views for the management of the program structure in the large and the various types of entities (classes, modules, procedures, forms,). (v) It is an Event Driven
Programming which provides complete control to the end user.(vi) VB is a first Programmer friendly language in the world. (vii) VB provides a comprehensive interactive and context-sensitive
online help system. (viii) When editing program texts the "IntelliSense" technology informs we in a little popup window about the types of constructs that may be entered at the current cursor
location. (ix) Visual Basic 6.0 features provide graphical, Integrated data access to any ODBC or OLE DB data source and additional database-design tools for Oracle and Microsoft SQL Server-
based databases.(x) New Web Development features bring the easy-to-use, component-based programming model of Visual Basic to the creation of HTML and Dynamic HTML (DHTML)-based
applications.(xi) VB is a component integration language which is attuned to Microsoft's Component Object Model ("COM"). (xii) COM components can be written in different languages and then
integrated using VB. (xiii) Interfaces of COM components can be easily called remotely via Distributed COM ("DCOM"), which makes it easy to construct distributed applications. Disadvantages of
VB:-(i) Visual Basic is a proprietary programming language written by Microsoft, so programs written in Visual Basic cannot, easily, be transferred to other operating systems. It's a platform
dependent, it only runs on MS Windows operating system.(ii) There are some, fairly minor disadvantages compared with C. C has better declaration of arrays - it's possible to initialize an array of
structures in C at declaration time; this is impossible in VB. Q.2. Explain in Detail the Need and Important of Visual Basic Programming .Ans. Need of Visual Languages or Importance of VB :-
Visual Basic is regarded as the third generation event-driven programming language. It was released in 1987. Being the first visual development tool from Microsoft, it is considered as one of the
most powerful programming languages. As compared to other computer programming languages, such as, C, C++, it is easy to learn and understand, provided that one has determination and
dedication to do so. Visual Basic programming language allows programmers to create software interface and codes in an easy to use graphical environment. VB is the combination of different
components that are used on forms having specific attributes and actions with the help of those components. On the one hand it allows programmers to develop windows based applications
rapidly; on the other hand, it helps greatly in accessing data bases, using ADO while letting the programmers use ActiveX con trols and various objects. While it is intended more to develop
applications, it is also useful for games development for particular or limited purposes, unlike C++ that is more suitable fo r developing games. As compared to other languages, Visual Basic may
be slower though, yet it is flexible and it can be rightly said that things that are difficult in other languages are comparatively easier in visual basic programming language. It may also be said that,
since it is one of the most popular programming languages, lots of related books and material and other resources are available and can be accessed for developing programming skills at visual
basic programming language conveniently .One of the most important things to be considered with regard to programming in Visual Basic is that the structure of VB is designed in a way that
allows programmers to create executable code - Exe files. It enables programmers to develop programs that can be used as front end to databases. Besides, it's with the help of visual basic tools,
one can change the abstract ideas into programs or into the whole software while it allows revising and modifying the programs fittin gly. Q.3. Write a Detailed Note on History or Evolution of
Visual Basic Ans. Evolution or History of Visual Basic :- BASIC (Beginners All Purpose Symbolic Instruction Code) was developed in 1960's by Prof. Kemeny & Kurtz. 1970's Bill Gate simplemented
BASIC in several PCs. Alan Cooper is considered the father of Visual Basic. In 1987, the then Director of Applications Software for Coactive Computing Corporation wrote a program called Ruby
(Tripod) that delivered visual programming to the average programmer/user. Alan Cooper developed VB and sold to Microsoft in 1988. The Visual Basic (VB) system is a fourth generation
programming system which produces much of the code itself as the programmer designs the interface for his or her application. Microsoft surveys in the late 1990's showed that roughly two-
thirds of all business applications programming on PCs was being done in Visual Basic. Visual Basic 1.0 for Windows was first released on May 20,1991 at the Windows World Convention in Atlanta
Georgia. VB version 2.0 for Windows (November 1992) was faster, more powerful and easier to use than version 1. VB 2 was also available in a freeware student release called the Primer Edition.
Visual Basic 3.0 (1993) added tools to access and control databases and Object Linking and Embedding (OLE) version 2. It came in Standard and Professional versions. A superset of VB, called
Visual Basic for Applications, was released as part of Microsoft Excel 5 and Microsoft Project 4 in 1993. It has since become the internal programming language of the Microsoft Office family of
products and is available for license by other software companies. Visual Basic 4 was released in 1995 and supported the new Windows 95 family of 32-bit operating systems. The Professional
Edition could also compile code to run on the older 16-bit Windows 3.x systems. Visual Basic Scripting Edition (VBScript) was also announced in 1995. VBScript is used to write embedded code for
inclusion in web pages, although not all web browsers will run VBScript. Q.4. Explain in Detail, Why Visual Basic is known as Event- Driven Programming Language. Or, Describe the Common
Properties of Event Driven Programming. Ans. The event-driven programming revolves around recognizing the occurrences of events and then responding to those events by taking appropriate
actions. In event-driven programming an application is build up as a series of responses to user-events. Visual Basic and Event Driven Programming :- In traditional or procedural application, the
application itself determines which portion of code is to be executed and in what sequence. Generally, execution starts with the 1st line of code and follow the coding sequence define in the
application. Where as application written in VB are 'Event-Driven'. In an event-driven application the code doesn't follow a pre-determined path rather it execute different code sections in
response to events. Event can be triggered by user's action, by message from system, other applications or even from the application itself. The sequences of these events determine the order in
which the code execute and associated with the objects of application. They either act on an object or are triggered by an object to control the flow of execution when it is running. That is why
VB called Event-Driven Programming Language. Properties of Event Driven Programming :- (i) Service Oriented Service oriented is a key features in event-driven programming that used to write
programs that are made for services and it takes does not slow down the computer as service oriented, only consume little of the computer processing power and usually services run in the
background of OS.(ii) Time Driven: In event driven programming, time driven is a paradigm, it's a code that runs on a time trigger, time driven can be a specific code that runs on a s p…Q.5. Is VB
a Full Object-Oriented Programming Language? Ans. There are many versions of VB exist in the market. The most popular one and still widely used by many VB programmers is none other than
Visual Basic 6. We also have VB.Net, Visual Basic 2005, Visual Basic 2008, Visual Basic 2010, Visual Basic 2012 and Visual Basic 2013. Among these versions VB2008, VB2010, VB2012 and VB2013
are fully Object-Oriented Programming (OOP) languages and other has event driven programming features. Visual Basic 2008 is very much similar to Visual Basic 6 in terms of syntaxes and program
structure, but their underlying concepts are very different. VB2008 is an Object-oriented Programming Language under the .NET framework. Although VB6 may have some OOP capabilities, it is
not an object-oriented programming language. Visual Basic 6 is not an object-oriented programming language because it does not have inheritance capabilities. On the other hand, VB2008 is an
Object-oriented Programming Language, just like other OOP such as C++ and Java. It is different from VB6 because it focuses more on the data itself while VB6 focuses more on the actions. VB6
is known as a procedural or functional programming language. Polymorphism: Can be achieved to an extent through interfaces (using Implements) although the ability to overload functions (for
example) doesn't exist and each "overload" would technically require a unique function name. We can work around this by passing in an object as the only parameter to a function or sub and
vary the procedure depending on the values of the properties. So while we can work with objects to an extent and MS Office applications are based around an object model, VBA is not truly an
Object-oriented language. Polymorphism cannot be achieved to the extent that we would be familiar with in C++.Hence, we can say that visual basic are many versions some are associated with
event driven and some are associated with Object- oriented programming, so visual basic is not completely Object-oriented language. Q.6. Discuss all the Characteristics and Features of Visual
Basic Ans. Characteristics and Features of Visual Basic :- Visual Basic (VB) is a unique computer language-at least it I was when it first came out. Now there are many imitators. VB allows us to
quickly and easily develop a bank of visual controls with sliders, switches and meters or a complex form for a user to fill out. It uses the BASIC language which is known to most computer
programmers and which can be learned quickly if it is not already known.(i) IDE: Integrated Development Environment (IDE) con sists of inbuilt compiler, debugger, editors and automation tools
for easy development of code. Visual Basic.Net 2006 IDE can be accessed by opening a new project. IDE consists of Solution Explorer, Toolbox, Form, Properties Window and Menu Bar. In Visual
Studio Windows related to a project are combined together and placed at certain locations on the screen. It also having the great feature called as drag and drop. We can d rag and the drop the
controls without writing single line of coding.(ii) GUI Interface or User Interface: VB is a Graphical User Interface (GUI) Language. This means that a VB program will always show something on the
screen that the user can interact with (usually via mouse and keyboard) to get a job done. The first step in building the VB program is to get the GUI items on the screen.(iii) Object-Oriented:
Object-Oriented Programming (OOP) is a concept where the programmer thinks of the program in "objects" (however abstract the objects may be) that interact with each other. In OOP, all the
code associated with that object is in one place. Once again, VB forces this good programming practice. The GUI items are the objects and all the code associated with the object are just a click
away. This natural way of enforcing good programming practices- plus the ease of programming in BASIC-is exactly why VB has found so many devoted fans. Visual Basic 6.Q.7. What Features are
Available in VB for Database Connectivity ? Ans. Applications communicate with a database, firstly, to retrieve the data stored there and present it in a user-friendly way and secondly, to update
the database by inserting, modifying and deleting data. Microsoft ActiveX Data Objects.Net (ADO.Net) is a model, a part of the .Net framework that is used by the .Net applications for retrieving,
accessing and updating data. For Database Connectivity Visual Basic use its following features :- (i) DAO: When Visual Basic first started working with databases, it used the Microsoft Jet Database
Engine, which is what Microsoft Access uses. To support the Jet Database Engine, Microsoft added the data control to Visual Basic and you can use that control to open Jet Database (.mdb) files.
Microsoft also added a set of Data Access Objects (DAO) to Visual Basic -• DBE ngine: The Jet Database Engine. • Workspace: An area can hold one or more .Database: A collection of tables ..Table
Def: The definition of a table .Query Def: The definition of a query. .Re cord se t: The set of records that make up the result of aquery . Field: A column in a table. Index: An ordered list of
records. Relation: Stored information about the specific relationship between tables The Remote Data Objects are designed in parallel with the Data Access Objects; for example, the database
engine is rdo Engine instead of DB Engine, Record sets have become rdo Result. Table Defs became rdo Tables, Workspaces became rdo Environments, Field objects became rdo Column objects
and so on. Although the names have changed, the command set is very similar to DAO.(v) ADO: Microsoft's latest set of data access objects are the ActiveX Data Objects (ADO). These objects let
you access data in a database server through any OLE DB provider.Q.8. Describe the Classification of Operator Type in VB with an Example. Ans. An operator is a special symbol which indicates
a certain process is carried out. Operators in programming languages are taken from mathematics. Programmers work with data. The operators are used to process data. Here the Operators used
in Visual Basic are :- (i) Arithmetical Operators: Arithmetical operators are use dto perform many of the familiar arithmetic operations that involve the calculation of numeric values represented
by literals, variables, other expressions, function and property calls and constants. Also classified with arithmetic operators are the bit shift operators, which act at the level of the individual bits
of the operands and shift their bit patterns to the left or right.(ii) Comparison/Conditional/Relational Operators :Comparison operators compare two expressions and return a Boolean value that
represents the relationship of their values. There are operators for comparing numeric values, operators for comparing strings and operators for comparing objects. Visual Basic compares numeric
values using six numeric comparison operators. Each operator takes as operands two expressions that evaluate to numeric values. The following table lists the operators and shows examples of
each. You can also compare strings with the above operators. However, there are certain rules to follows-Upper case letters are less than lower case letters, "A" < "B" < "C" < "D" ....... <"Z" and
numbers are less than letters.(iii) Logical Operators: In addition to conditional operators, there are a few logical operators which offer added power to the VB programs. Logical operators compare
Boolean expressions and return a Boolean result. The And, Or, And Also, Or Else, and X or operators are binary because they take two operands, while the Not operator is unary because it takes
a single operand. Some of these operators can also perform bitwise logical operations on integral values.Q.9. What is File Handling in VB? Explain Important Types of File Handling in VB. Ans.
File Handling: A file is a collection of data stored in computer memory with a specific name and a defined folder path. Every development tool provides access to these files on the disk. The term
File Handling in Visual basic is used to perform various operations like create a file, read a file, write to the file, closing the file and more. Furthermore, when a file is opened for reading and writing,
a stream is created. There are three special controls, called as File Controls, which deal with files and directories. Processing the file, i.e. either reading the content of the file or writing the required
data into file or both. Defining New Terms :-Record: One logical section of a file that holds a related set of data. If the file contains Student information, a record would hold the information on
one student-name, address, student ID, etc. If there are 5,000 students registered, the file contains 5,000 records. Whenever we work with a file we have to have ways of reading data from the
file (that's Input) and ways of writing data to the file (that's Output). I/O operations consist of all those c ommands that let we read and write files. Types of Files :-There are basically three types
of files we can work with(i) Sequential File iii) Binary File: This is a special, compacted form of the random file. Data is stored at the byte level and we can read and write individual bytes to the
file. This makes the file access very fast and efficient. We won't be covering this type of file in these exercises. If we need to find out more about it, go to the VB Reference Manual. Access Mode
:(i) For Mode in the Open Statement indicates how the file will be used. There are five access modes. (ii) Input: Open for sequential input; the file will be read sequentially starting at the beginning.
(iii) Output: Open for sequential output; records will be written sequentially starting at the beginning; if the file does not exist, it is created; if it does exist, it is overwritten.Q.10. What do we
Mean by (IDE) Integrated Development Environment. Explain the Different Types of VB Environment. Ans. IDE stands for Integrated Development Environment. When multiple operations
performed in single window is called IDE. In this environment user can create, edit executed and debug on 15 single platform. Its main functions include writing, compi ling and debugging code,
monitoring resources. It is intended as a set of tools that all work together. An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to
computer programmers for software development. An IDE normally consists of a source code editor, build automation tools and a debugger. Visual Basic & Integrated Development Environment
:- Visual Basic Environment is an IDE (integrated development environment) of Microsoft. Graphical user interface is used with a basic programming language; it is a first product to provide a
graphical programming environment for developing a user interface. In this environment, substantial amount of code is replace d by the controls, where just dragging and dropping is enough to
add the control in the interface. This environment does not have an object-oriented programming language concept. Attributes and event handling are associated with the controls; default values
are assigned to the controls while it is created and it is possible to change the default values We must close one document in order to open another. A SDI application usually doesn't contain
window menus on its menu bar because we can't move between data windows. When user opens new data file, the data replace the data currently shown in the open window. boo (ii) Multiple
Document Interface (MDI): In MDI we can open more than one document at the same time. The MDI has a Q.11. What are the Immediate Windows, Edit View and Tool Bar in Visual Basic. Or,
Explain Each of Visual Basic Components. Or, Explain Toolbox, Properties Windows, Form Designer, Code Window and Immediate Window in Detail. Or, Explain the Project Explorer and Properties
Windows in VB with Example. Or, Explain Various Type of Components in VB. Ans. A visual basic window is also called integrated development environment (IDE) window. This window open
when we click on standard exe icon from new project dialog box. When we open a visual basic project window which is also called IDE window, its components are displayed in the following
format :- Titte Barks324 Menu Bar Standard Toolbar Paplect Explorer Form Window Project Window Form Layout Window The IDE in VB (visual basic) consists of the following components.
Those are :- (i) Title bar: A title bar is the horizontal bar located the top of the screen. It includes the project name, an icon that closes visual basic at the left and icon that minimize the group
window, change the size of the group or close visual basic on right. This component is common for all window application. (ii) Menu bar : The menu bar is also common for all document windows.
It contents command required and build an application. The main menu items have some menu items that can be chosen when needed. (iii) Tool bar: The tool bars give us quick access to
commonly used menu command. Beside the main tool bar, which displays b [17:13, 20/02/2023] Hi:): tool bar for specific purpose. The four built in tool bar are standard, edit, debug and from
editor. By default, standard tool bar appear immediately below the menu bar. (iv) Project explorer: The docked on the right side of the screen and just below standard tool bar, is the project
explorer window. The project explorer window, serve as a quick reference to the various element of a project namely form, class and module. All the objects that make up the application are
packed in a project. The project explorer window holds the file name for the file included in our project. A window's title bar holds the name our project with .VBP file extension, which is project
one by default until we save it with a new name. A simple project typical contents one form, which is window that is designed as part of the program interface. It is possible to develop any number
of forms in a program. (v) Tool box: The tool box contains the icon of the control we can place on a form to create the application's user interface. By default tool box contains a pointer icon and
twenty other icon of ActiveX controls. The tool box appear at the left side on screen by default. User can change its position anywhere on the form. Even tool box can be turn off on screen. To
place a control on a form, we first select it with a mouse and then move the mouse over the form. When the mouse is over the form, the curser turns into a large plus sign and we can draw control
on the form, just as we would draw a circle using a drawing application. The size of the circle determines the size of the control. (vi) Properties window: Every object has properties associated
with it. The properties window is docked under the project explorer window. The properties window allows us to assign or change properties associated with a particular object. Properties are
attributes such as size, position etc. like a form, each control has its own set of properties. Some properties like width, height are common to both form and controls, while other properties are
unique to form or control. Control offend differ in the number and type of properties. (vii) Form layout window: The form layout window specifies a form's position on the screen at run-time.
The form layout window appear below the properties window. It consist of an image representing the screen and the form's relative position on the screen. With the mouse pointer positioned
over the form image, draw it to the new location. Note that the mouse pointer changes shape when moved over the image representing the form. (viii) Form window: A form window used in
visual basic to create project inside the form. A form window appear on screen just [17:14, 20/02/2023] Hi:): like grid of dots inform of matrix. We can increase or decrease size of form window
according to our need. By default only one form window will appear on screen but more than one form window can be open on the project window. Out of multiple form windows, one window
is called master window and other are called slave windows. By default first window automatically treated as master window. But user can change or select any one window as a master window.
Remaining window are automatically changed to slave window. (ix) Project window: Only one project window will appear on screen when we open visual basic window. This project window
appears beside the form window. User can not add another project in the current project. By default na me of a project is project1 and its file name is project1.vbp, but user can change project
name as well as project file as needed. Q.12. What is Form? How can we Create the Form and Manage at Run-time? Also Discuss the Common Properties and Events of Form. Ans. Visual Basic
Form is the container for all the controls that make up the user interface. Every window we see in a running visual basic application is a form, thus the terms form and window describe the same
entity. Visual Studio creates a default form for us when we create a Windows Forms Application. Every form will have title bar on which the form's caption is displayed and there will be buttons
to close, maximize and minimize the form. If we click the icon on the top left corner, it opens the control menu, which contains the various commands to control the form like to move control
from one place to another place, to maximize or minimize the form or to close the form. Q.13. What do we Mean by SDI and MDI Form ? How can we Create an MDI Form ? Discuss the Steps
for Creating a Menu in MDI Form. Ans. SDI and MDI Forms in VB:- The SDI and MDI forms are the interface design for document handling within a single Windows application. The MDI stands
for Multiple Document Interface whereas SDI stands for Single Document Interface. MDI: A Multiple Document Interface is one that allows viewing multiple windows within a large window. SDI:
A Single Document Interface is one where all Windows appear independently of one another without the unification of a single parent window. The Visual Basic IDE can be viewed in two ways:-
(i) With the Multiple Document Interface (MDI), (ii) Single Document Interface (SDI). MDI view shows all the distinct windows of Visual Basic IDE as child windows within on large IDE Window. In
the SDI view, distinct windows of the Visual Basic IDE exist independently of each other. [17:15, 20/02/2023] Hi:): MDI Forms: This is the main form or parent form which is not duplicated, but
acts like a container for all the Windows which is also called the Primary Window. The windows in which the individual documents are displayed are called Child Windows. An MDI application
must have atleast two form, the primary parent form and one or more child forms. The parent form may not contain any controls, While the parent form is open in design mode, the icon on the
tool box are not displayed, but you can't place any control on the form. The parent form usually have a menu. In short, the MDI applications act as the parent and child relationship in a form. A
parent form is a container that contains child forms, while child forms can be multiple to display different modules in a parent form. MDI VB has following rules for creating a form as an form- (i)
MidParent: The MidParent property is used to set a parent form to a child form. vos al 11 bebol (ii) ActiveMdiChild: The ActiveMdiChild property is used to get the reference of the current child
form. (iii) IsMdiContainer: The IsMdiContainer property set a Boolean value to True that represents the creation of a form as an MDI form. (iv) LayoutMdi(): The LayoutMdi() method is used to
arrange the child forms in the parent or main form. (v) Controls: It is used to get the reference of control from the child form. To Create an MDI Form follow these steps :- Start a new project
and then choose :- Project -> Add MDI Form to add the parent form. M Set the Forms caption to MDI window. Choose Project -> Add Form to add a SDI window. Make this form as child of MDI
form by setting the MDI child property of the SDI form to True. Q.14. Discuss the Visual Basic Programming Development Process with the help of Example. Merriw (0 Ans. Visual basic or VB
is an "event driven programming language and "integrated development environment" of Microsoft. "Graphical user interface" is used with a basic programming language; it is the first product
to provide a graphical programming environment for developing a user interface. [17:16, 20/02/2023] Hi:): Q.15. What are the Different Types of Scroll Bar in VB. Write ertt a Program to
Demonstrate the use of Scroll Bars in VB. Ans. The Scroll Bar controls display vertical and horizontal scroll bars on the form. This is used for navigating through large amount of information. alls
al lostno od na There are two types of scroll bar controls :- (i) HScrollBar for horizontal scroll bars and (ii) VScrollBar for vertical scroll bars. These are used independently from each other.
Properties of the Scroll Bar Control :- The following are some of the commonly used properties of the Scroll Bar control :- [17:16, 20/02/2023] Hi:): Q.16. What do We Mean by Array in VB?
Explain Static and Dynamic Array with Suitable Example. Define Array. What are Different Types of Array in VB? How we can make Dynamic Array in VB? Explain with Or, Example. Ans. An
array is a variable with a single name that represents many different items. When we work with a single item, we only need to use one variable. However, if we h ave a list of items which are of
similar type to deal with, we need to declare an array of variables instead of using a variable for each item. For example, if we need to enter one hundred names, it is difficult to declare 100
different names. Besides, if we want to process those data that involves decision making, we might have to use hundreds of if...then statements, this is a waste of time and efforts. So, instead of
declaring one hundred different variables, we need to declare only one array. We differentiate each item in the array by usin g subscript, the index value of each item, for example, name(1),
name(2), name(3) .......etc., makes declaring variables more streamline. The Individual elements of an array are identified using an index. Arrays have upper and lower bounds and the elements
have to lie within those bounds. Each index number in an array is allocated individual memory space and, therefore, users must evade declaring arrays of larger size than required. We can declare
an array of any of the basic data types including variant, user-defined types and object variables. The individual elements of an array are all of the same data type. There are two types of arrays
in Visual Basic namely:- (i) Fixed-size/Static Array: The size of array always remains the same-size doesn't change during the program execution. (ii) Dynamic Array: The size of the array can be
changed at the run-time-size changes during the program execution. Declaring Arrays: Arrays occupy space in memory. The programmer specifies the array type and the number of elements
required by the array so that the compiler may reserve the appropriate amount of memory. Arrays may be declared as Public (in a code module), module or local. Module arrays are declared in
the general declarations using keyword Dim or Private. Local arrays are declared in a procedure using Dim or Static. Array must be declared explicitly with keyword "As". Declaring One Dimensional
Array: The general syntax to declare a one dimensional array is as follow:- Dim arrayName(subscript) as dataType [17:17, 20/02/2023] Hi:): Where subs indicate the last subscript in the array. 27
When you declare an array, you need to be aware of the number of elements created by the Dim keyword. In the Dim arrayName(subscript) statement, subscript actually is a constant that defines
the maximum number of elements allowed. When an upper bound is specified in the declaration, a Fixed-array is created. The upper limit should always be within the range of long data type.
Example: Dim numbers(5) As Integer. In the above illustration, numbers is the name of the array and the number 6 included in the parentheses is the upper limit of the array. The above
declaration creates an array with 6 elements, with index numbers running from 0 to 5. The second way is to specify the lower bound and the upper bound of the subscript using To keyword. The
syntax is :- Dim arrayName(lowerbound To upperbound) As dataType If we want to specify the lower limit, then the parentheses should include both the lower and upper limit along with the To
keyword. An example for this is given below. [17:17, 20/02/2023] Hi:): Q.17. Discuss the Concept of VB Project, Creating Opening and Saving the Projects. Ans. In Visual Basic, a project is the
group of all the files that make up your program. These might include forms, modules (blocks of code not attached to a form), graphics and ActiveX controls. A project is create our program, and
each form, module, graphic and ActiveX control is saved as an individual file. Detailed information about all our program's files is stored in the project file. The project file lists all the files that our
program uses, as well as details, such as the project name and how the IDE should be configured while we work on this particular project. Project files have the extension VBP. Creating Visual
Basic Project: When we select visual basic application from either desktop or from other option, a dialog box [17:18, 20/02/2023] Hi:): with a visual basic window will appear. Visual basic window
will activate any when user select any one option out of multiple option. A new project dialog box contains three tabs namely new, existing and recent. By default new tab is selected. If user
selects existing or recent tab, name of project file will appear instead of icon. There are number of icon appears including standard exe, ActiveX exe, ActiveX dll, ActiveX control, ActiveX document
exe, ActiveX document dll, V.B. application wizard, V.B. wizard manager, data project, DHTML, IIS application, ADDIN and V.B. enterprise edition control. Standard exe: This icon is commonly in
use become standard exe is used for open new project and user can create their project using this application. Most of the applications in visual basic are connected with standard exe project.
ActiveX exe and ActiveX dll: Both ActiveX components are OLE automation server. ActiveX components are basic code building components that do not have a visible interface and that can add
special functionality to our application. ActiveX control: An ActiveX control such as a text box or a command button control, is a basic element of the user interface. If the ActiveX control that
comes with visual basic not provide functionality we need, we can build our own custom controls. ActiveX document exe and ActiveX document dll: Both ActiveX documents are essential for
documentation. It can run in the environment of a container that support hyperlinking. Opening a Visual Basic Project: If a project is already exist, user can open it in two different ways. One way
to open an existing project by using new project dialog box. When this dialog box appear on screen with three tabs name ly new, existing and recent. Select either existing or recent tab from the
dialog box. An existing tab display all visual basic project files. Select one project file and click on it. A recent tab work similar to existing tab but it displays only few visual basic project file which
are recently develop by the user. Select a file and click on the open button. In both cases, a visual basic project will open in visual basic window. [17:18, 20/02/2023] Hi:): Q.18. What do we
understand by Methods and Events? Explain with Example ? Ans. Methods: A method is an action that can be performed on objects. For example, a cat is an object. Its properties might include
long white hair, blue eyes, 3 pounds' weight etc. A complete definition of cat must only encompass on its looks, but should also include a complete itemization of its activities. Therefore, a cat's
methods might be move, jump, play, breath etc.unoly Xovi A Similarly, in Object-oriented programming, a method is a connected or built-in procedure, a block of code that can be invoked to
impart some action on a particular object. A method requires an object to provide them with a context. For example, the word Move has no meaning in Visual Basic, but the statement, O Text1
Move 700, 400 performs a very precise action. The TextBox control has other associated methods such as Refresh, SetFocus, etc. on pied Isuely lis The Refresh method enforces a complete repaint
of the control or a Form. For example, Text1.Refresh refreshes the TextBox. The Setfocus method moves the focus on the control. For Example Text1.SetFocus sets the focus to TextBox control
Text1. Events: An event is a signal that informs an application that something important has occurred. For example, when a user clicks a control on a form, the form can raise a Click event and
call a procedure that handles the event. Programs need to do something in [17:18, 20/02/2023] Hi:): response to user actions and actions initiated by the operating system. 31 Such actions, which
are external to the program itself (although they may be triggered by the program) are called events. Keyboard and Mouse are two most important input devices. When user uses these devices,
Visual Basic generates a set of events. Types of Events :-r (i) Keyboard Events: When user presses a key on the keyboard, Visual Basic generates a few events. These events allow user to know
which key is exactly pressed. Keyboard events occur for the controls that can receive input (have focus). The following are the keyboard events available in Visual Basic:- (a) KeyDown and KeyUp
Events: Keydown event occurs when user has pressed a key from keyboard. KeyUp event occurs when user releases a key that he has pressed earlier. That means every KeyDown event is followed
by a KeyUp event. These events occur for all types of keys including special keys like F1 and Home key. (b) KeyPress Event: Keypress event occurs when user presses and releases a key. This event
occurs only when user presses one of the ANSI keys such as alphabets, digits etc. This event doesn't occur when user presses arrow keys, function keys etc. (ii) Mouse Events: Mouse events occur
when user presses and releases mouse buttons. The following are the events related to mouse or botnet 150 V primmerpo nov Event When does it Occur? Insva bas banano how Click; When
user presses and releases a mouse button. Dblclick; When user presses and releases and again presses and releases a mouse button. MouseDown; When user presses a mouse button.
MouseUp; When user releases a mouse button. • MouseMove; When user moves mouse pointer. Q.19. What do We understand by Event Driven Programming. p List and Explain about some
of the Events Supported by VB Object. Bonpong arif to wont sill forw ni mp Or, What is Event Driven Programming? How does it Differ with Procedure-Oriented Programming? Ans. Event
Driven Programming: Event-driven programming is a programming paradigm in which the flow of program execution is determined by events; for example, a user action such as a mouse click,
key press, or a message from the operating system or another [17:19, 20/02/2023] Hi:): program is known as the Event Driven Programming. VB Programming is also based on Events. An event
driven application is designed to detect events as they Occur and then deal with them using an appropriate event handling procedure. When we fire an event, the code in the event procedure is
executed and then visual basic performs its operations as per the instructions written in the event procedure code. For example, in the first sample program, when we click the 'Print' button, the
click event is fired and then the code in the click event procedure gets executed. The code tells Visual Basic to print a text on the form. So as a result, we see a text printed on the form. Example:
Write the following code in the DblClick event procedure of the form:- Private Sub Form_DblClick() Print "You have double-clicked" End Sub Output When we double-click on the form, the
DblClick event procedure of the Form object is invoked and then the code in the DblClick event procedure is executed. Thus, the code instructs Visual Basic to print a text on the form. Event Driven
Programming Vs Object Oriented Programming:- Object Oriented and Event Driven Programming are both very important programming techniques that are used in our modern world of software
development. In the process of learning how to program with various programming languages, it is important for us to be able to know what exactly is the difference between object oriented and
event driven programming techniques. Object Oriented Programming is a programming language model that is organised around objects rather than actions (which are used in event driven
programming) and data rather than logic... On the other hand, event driven programming is a programming paradigm in which the flow of the program is determined by events such as user
actions (mouse clicks, key presses), sensor outputs or messages from other programs or threads [17:19, 20/02/2023] Hi:): Q.20. What are the Different Data Types Supported by Visual Basic.
How they can be Declared? Also Mention their Uses. Or, Briefly Explain the Different Data Types Available in Visual Basic with Example? Ans. By default, Visual Basic Variables are of variant
data types. The variant data type can store numeric, date/time or string data. When a variable is declared, a data type is supplied for it that determines the kind of data they can store. The
fundamental data types in Visual Basic including variant are integer, long, single, double, string, currency, byte and boolea n. Visual Basic supports a vast array of data types. [17:20, 20/02/2023]
Hi:): Each data type has limits to the kind of information and the minimum and maximum values it can hold. In addition, some types can interchange with some other types. A list of Visual Basic's
simple data types are given below:- (i) Numeric:- Byte Store integer values in the range of 0-255. Store integer values in the range of (-32,768) Integer (+32,767). Store integer values in the
range of (-2,147,483,468) (+2,147,483,468). Long Single Store floating point value in the range of (-3.4x10- 38) (+ 3.4x1038). Double Store large floating value which exceeding the single data
type value. Currency Store monetary values. It supports 4 digits to the right of decimal point and 15 digits to the left. (ii) String: Used to store alphanumeric values. A variable length string can
store approximately 4 billion characters. (iii) Date: Used to store date and time values. A variable declared as date type can store both date and time values and it can store date values 01/01/0100
up to 12/31/9999. (iv) Boolean: Boolean data types hold either a true or false value. These are not stored as numeric values and cannot be used as such. Values are internally stored as -1 (True)
and 0 (False) and any non-zero value is considered as true. (v) Variant: Stores any type of data and is the default Visual Basic data type. In Visual Basic if we declare a variable with out any data
type by default the data type is assigned as default. A variant is a data type that knows how to be any data type. If we declare a variable to be of type variant, it can be an Integer, Double,
String...whatever. Variables have a definite use in advanced programming. In all probability, in 90% of our applications we will use at most six types-String, Integer, Long, Single, Boolean and Date.
The Variant type is often used automatically when type is not important. A Variant- type field can contain text or numbers, depending on the data that is actually entered. It is flexible but it is not
very efficient in terms of storage. [17:20, 20/02/2023] Hi:): Q.21. Discuss in Detail the Control Statements of Visual Basic. Or, Or, Explain with Example Control Flow Statement, Conditional and
Loop in VB. Discuss the Conditional Statements of Visual Basic Programme. Ans. Control statements are used to create special program feature, such as logic tests, loops are branches. There
are two types of control statements in VB. They are :- Control flow statements _statements such as If... If...Then...Else and select...case. Then, Loop statements such as Do loop, for...Next
and while div...wend. Control Flow Statements :- note The if statements: An If statement is used to redirect program flow based on the result of a conditional test. These are two forms of If
statements :- • If... Then statement. If...Then...Else statement. The If...Then: Structure tests the condition specified, and if it is true, executes the statements that follows. The If structure can
have a single-line or multiple line syntax as follows:mode If condition Then statement Condition can be any expression that evaluates to a true or false value. In VB True is defined as any non-
zero number, such as- 1, 1, 2, 500 and so on. On the other hand False has a value zero (0). Example: If intcount < 10 Then intcount= intcount + 1. The multiple-line If statement has the following
syntax :- Then Once or more VB statements If condition End if. [17:22, 20/02/2023] Hi:): If we want to execute only one statement when a condition i true, we can write the code on one line :-
If i 10 Then response.write("Hello"). There is no ..Else.. in this syntax. We just tell the code to perform one action if a condition is true (in this case If i=10). If we want to execute more than one
statement when a condition is true, we must put each statement on separate lines and end the statement with the keyword "End If" :- If i = 10 Then response.write("Hello") i = i + 1 End If. There
is no ..Else.. in the example above either. We just tell the code to perform multiple actions if the condition is true. If we want to execute a statement if a condition is true and execute another
statement if the condition is not true, we must add the "Else" keyword :- Example : i = hour(time) If i 10 Then response.write("Good morning !") Else response.write("Have a nice day !") End
If. In the example above, the first block of code will be executed if the condition is true, and the other block will be executed otherwise (if i is greater than 10). [17:23, 20/02/2023] Hi:): Q.22.
What Type of Connectivity Can be used to Connect MS. Access Database to Visual Basic Form? Explain with Step of Connectivity. Ans. Creating a Database : Before using a database on the
form we must create a database. This database work as DAO. This database work similar to Microsoft access. It contains number of data field such as text, memo, number, date/time, c urrency,
auto number, logical and OLE Object. Visual data manager application that is included with visual basic allow us to create database. To open and create a database with visual data manager,
follow the following steps:- (1) Start visual basic and click add-Ins on the menu bar. list of menus option appears, select visual data manager. A (ii) A visual data manager window will open. Click
file on the menu bar, then click new on the file menu. A sub-menu opens. Click Microsoft access. Another sub-menu opens. Click version 7.0 MDB. The select Microsoft access database to create
dialog box appear. Use the dialog box to locate a folder where we wish to save the database file. Enter file name, visual data manager automatically saves the file with .MDB extension. (iii) Now
we will add a table to database file. Right click in the database window. On the popup menu that appears, click new table. The table structure dialog box appears. (iv) Type table name in the table
name text box. Now table is saved in .DBF file extension. [17:23, 20/02/2023] Hi:): (v) Click the add field button in the table structure dialog box type. The add field dialog box will appear. In the
name text box, type field name and in the type list box, select a field Click OK button to select the field. (vi) The add field dialog box still display. Type another fiel name and field type and click OK
button every time. (vil) After adding last field, click the close button on the add field dialog box. The table structure dialog box reappear In this dialog box, we can edit in field structure.co (viii)
Click the build the table button to build the table and add it to database. The visual data manager window should appear all screen. Notice that on entry for the table new appear will appear. (ix)
Now we are ready to add data to the table. Right click the table name entry in the data base window and select open from the popup menu. (x) Click the add button. The Dynaset add record
dialog box. Should appear on screen. Enter the record value of each field and click update button. (xi) Second record is now added to the table. Add the dynaset dialog box click the add button
to add the next record. Continue this procedure to add all the remaining records in the table. (xii) After we have added all the records in the table, click the close button in the dynaset dialog
box.. (xiii) Click file on the visual data manager menu bar. On the file menu, click exit button. Now we return to the visual basic form window. Q.23. Write Different Error Handling Techniques in
VB in Detail Ans. Error handling is an essential procedure in Visual Basi programming because it can help make the program error-free. A error-free program can run smoothly and efficiently and
the use does not have to face all sorts of problems such as program crash of system hang.. Errors often occur due to incorrect input from the user. For example, the user might make the mistake
of attempting to ask the computer to divide a number by zero which will definitely cause a system error. Another example is the user might enter a text (string) to a box that is designed to handle
only numeric values such as the weight of a person, the computer will not be able to perform a [17:24, 20/02/2023] Hi:): arithmetic calculation for text, therefore will create an error. These errors
are known as synchronous errors. 39 There are three types of errors in programming-(1) Syntax Errors, (ii) Run-time Errors and (iii) Logical Errors. (i) Syntax Errors: Syntax errors, also called as
parsing errors, occur at the interpretation time for VBScript. For example, the following line causes a syntax error because it is missing a closing parenthesis. Function ErrorHandling Demo() Dim
x,y x = "Tutorialspoint" y = Ucase(x End Function (ii) Run-time Errors: Run-time errors, also called exceptions, occur during execution, after interpretation. For example, the following line causes
a run-time error because here the syntax is correct but at run-time it is trying to call fnmultiply, which is a non-existing function. Function ErrorHandling Demo1() Dim X,Y X = 10 y = 20 z =
fnadd(x,y) a fnmultiply(x,y) End Function Function fnadd(x,y) fnadd = x + y End Function (iii) Logical Errors: Logical errors can be the most difficult type of errors to track down. These errors are
not the result of a syntax or run-time error. Instead, they occur when you make a mistake in the logic that drives your script and you do not get the result yo u expected. You cannot catch those
errors, because it depends on your business requirement what type of logic you want to put in your program. For example, dividing a number by zero or a script that is written which enters into
infinite loop. Error Object : Assume if we have a run-time error, then the execution stops by displaying the error message. As a developer, if we want to capture the error, then Error Object is
used. [17:25, 20/02/2023] Hi:): Example: In the following example, Err.Number gives the error number and Err.Description gives the error description. Err.Raise 6 Raise an overflow error. MsgBox
"Error # " & CStr(Err.Number) & "" & Err.Description Err.Clear Clear the error. Error Handling: VBA enables an error-handling routine a can also be used to disable an error-handling routine.
Without an On Error statement, any run-time error that occurs is fatal; an error message is displayed and the execution stops abruptly. and On Error GoTo [line | 0 | -1] | Resume Next } Keyword
Description GoTo line Enables the error-handling routine that starts at the line specified in the required line argument The specified line must be in the same procedure as the On Error statement,
or a compile-time error will occur. GoTo 0 Disables the enabled error handler in the current procedure and resets it to Nothing. Disables the enabled exception in the current procedure and
resets it to Nothing. Specifies that when a run-time error occurs, the control goes to the statement immediately following the statement where the error occured and the execution continues
from that point. GoTo -1 Resume Next Example : Public Sub OnErrorDemo() On Error GoTo ErrorHandler Enable error-handling routine. Dim x, y, z As Integer x = 50 y = 0 z = x/y Divide by ZERO
Error Raises ErrorHandler: Error-handling routine. Select Case Err.Number Evaluate error number. Case 10 Divide by zero error MsgBox ("You attempted to divide by zero !") Case Else MsgBox
"UNKNOWN ERROR - Error # " & Err.Number & ";" & Err.Description End Select Resume Next Q.24. Define Loop. How many Type of Loops are used in VB? Explain with Example. 41 Or, Describe
about the Various Looping Structure used in Visual Basic. Or, What do we Mean by Iteration? Explain Three Iteration Structures of VB with Example. Ans. Iteration (Looping) Statements:
There are many situations in which we will want to do the same thing again and again, perhaps slightly changing a value each time we repeat the action. This is called iteration or looping. Typically,
we'll iterate (or loop) over a set of items, taking the same action on each. This is the programming equivalent to an assembl y line. On an assembly line, we might take a hundred car bodies and
put a windshield on each one as it comes by. In an iterative program, we might work our way through a collection of text boxes on a form, retrieving the value from each in turn and using those
values to update a database. VB provides an extensive suite of iteration statements, including Do, For and For Each. We can a lso create a loop by using a statement called Goto. In short, Visual
Basic procedure that allows the program to run repeatedly until a condition or a set of conditions is met. This procedure is known as looping. Looping is a very useful feature of Visual Basic because
it makes repetitive works easier. There are three kinds of loops in Visual Basic, the Do...Loop, the For.......Next loop and the While.....Wend Loop. (i) Do...Loop: The Do...Loop executes a block of
statements for as long as a condition is True. Visual Basic evaluates an expression, and if it's True, the statements are executed. If the expression is False, the program continues and the statement
following the loop is executed. The Do Loop statements have four different forms, as shown below:- to su (a) The Do While...Loop is used to execute statements until a certain condition is met.
(b) The Do...Loop While statement first executes the statements and then test the condition after each execution. (c) Unlike the Do While... Loop repetition structures, the Do Until... Loop
structure tests a condition for falsity. Statements in the body of a Do Until...Loop are executed repeatedly as long as the loop-continuation test evaluates to False. [17:26, 20/02/2023] Hi:): (d) Do
Block of one or more VB statements Loop Until condition An example of a basic loop is as follows:- . Do Debug.Print "Hello" Loop Until x 10, This loop will print hello several times, depending
on the initial value of x. As you may have noticed, Do loops have no built in counters. However, they may be made manually as shown above. In this case, I chose x as my counter variable and
every time the loop execute, increase itself by one. When X reaches 10, the loop will cease to execute. The advantage of Do loops is that you may exit at any time whenever any certain conditional
is met. You may have it loop as long as a certain variable is false, or true, or as long as a variable remains in a certain range. (ii) The for...next loop: The syntax of a For..Next loop has three
components-a counter, a range and a step. A basic for..next loop appears as follows:- For X 1 To 100 Step 2 Debug.Print X Next X In this example, X is the counter, "1 to 100" is the range and
"2" is the step. When a For..Next loop is initialized, the counter is set to the first number in the range; in this case, X is set to 1. The program then executes any code between the for and next
statements normally. Upon reaching the next statement, the program returns to the for statement and increases the value of the counter by the step. In this instance, X will be increased to 3 on
the second iteration, 5 on the third, etc. To change the amount by which the counter variable increases on each iteration, simply change the value of the step. For example, if you use a step 3, X
will increase from 1 to 4, then to 7, 10, 13, and so on. When the step is not explicitly stated, 1 is used by default. (Note that the step can be a negative value. For instance, for X = 100 to 1 step-1
would decrease the value of X from 100 to 99 to 98, etc.) When X reaches the end of the range in the range (100 in the example above), the loop will cease to execute and the program will
continue to the code beyond the next statement. Q.25. Explain the Various Types of Error that may occur in VB. Discuss How to Avoid them. Or, Explain Type of Errors in VB with the help of
Example. Ans. When using application, a user may encounter various types of problems, some of which could come from us by some negligence when we worked on the project. Some other
problems could occur only at the time the application is being used. Some other problems could be caused by the computer on which the application is being used. While developing our application,
we should anticipate as many problems as possible as take appropriate actions. There are three main types of errors that could occur while our application is being used:- (i) Syntax Errors: A
syntax error comes from our mistyping a word or forming a bad expression in your code. It could be that we misspelled a keyword such as ByVel instead of ByVal. It could also be a bad expression.
Examples are:- 524++ 62.55 if Number == 2 Number = 6 If we use the Microsoft Visual Basic IDE to write our code, it I would point out the errors while we are writing our code, giving up time to
fix them. There are other syntax errors that the IDE may not detect. This could come from using a data type or class that doesn't exist. When we compile our application, the compiler can let we
know about other syntax errors. Those types of errors are those the compiler [17:27, 20/02/2023] Hi:): cannot execute. It this case, the compiler intercepts, stops and lets we know. For this
reason, syntax errors are almost the easiest to fix. Most of the time, the compiler would point out where the proble is so we can fix it. (ii) Run-Time Errors: After all syntax errors have been fixed,
the program may be ready for the user. The time period a person is using an application is called run-time. There are different types of problems that a user may face when interacting with our
program, For example, imagine that, in our code, we indicate that a picture would be loaded and displayed to the user but we forget to ship the picture or the directory of the picture indicated in
our code becomes different when a user opens our application. In this case, when you compiled and executed the application in our machine, everything was fine. This is a type of run-time error.
Run-time errors are mostly easy to fix because you will know what the problem is occurring and why. (iii) Logic Errors: These are errors that don't fit in any of the above categories. They could be
caused by the user misusing our application, a problem with the computer on which the application is running while the same application is working fine in another computer. Because logic errors
can be vague, they can also be difficult to fix. Q.26. Explain Designing the User Interface, Creating from the Code Modules. Ans. A program's user interface enables the user to interact with the
program. The user interface comprises any object that the user manipulates in order to give commands or information to the program. Such objects include buttons, menus and text boxes, to
name just a few. Visual Basic makes it easy to create a user interface by providing a set of ready-to-go controls in a toolbox. All we have to do to create our user interface is start a new project
and position the controls on the form, which is the object that represents the program's main window. Start creating our user interface, we follows these steps:- (1) Click the New Project button
in the Visual Studio Home Page. (ii) When the New Project dialog box appears, click Visual Basic .NET Projects in the Project Types box and then click the Windows Application. (iii) Next, we must
tell Visual Basic .NET the name of the program and where you want it stored on your hard drive. In the Name box type MyProgram (after deleting the default name, [17:27, 20/02/2023] Hi:): of
course), and in the Location window, type the location you want or just leave it set to the default, which should be the Visual Studio Projects that was automatically created when you installed
Visual Studio .NET. (iv) Finally, click the OK button and Visual Basic .NET will create a Form object for our program's window, as well as display a bunch of goodies in the Toolbox, Solution Explorer
and Properties window. Click the Windows Forms button at the top of the toolbox. Each icon represents one of the controls we can use to build our program's user interface :- (1) To create a
Visual Basic .NET application, you build a user interface, write the program source code and then compile the program into an executable file. (ii) You build a user interface by placing controls
from the Visual Basic .NET toolbox onto your program's form. (iii) You can resize controls (and the form) by dragging the con trol's sizing handles, which appear when the control is selected. (iv)
One way to display the code window is to double-click the object for which you want to write program code. (v) When the user clicks a button, Visual Basic .NET generates a C lick event. The
program code you add to the button's Click event procedure determines what the button does. (vi) The Build menu's Build (or Rebuild) command converts your Visual Basic .NET program into
a standalone Windows application. Q.27. What do we Mean by Procedures? Discuss Various Type of Procedures Available in VB with Suitable Example. Or, Explain Procedure, General
Procedure and Event Procedure. Ans. Visual Basic programs can be broken into smaller logical components called Procedures. Procedures are useful for condensing repeated operations such as
the frequently used calculations, text and control manipulation etc. The benefits of using procedures in programming are :- (i) It is easier to debug a program a program with procedures, which
breaks a program into discrete logical limits. (ii) Procedures used in one program can act as building blocks for other programs with slight modifications. [17:27, 20/02/2023] Hi:): Type of Procedure
:- A Procedure can be Sub, Function or Property Procedure, (i) Sub Procedures: A sub procedure can be placed in standard, class and form modules. Each time the procedure is called, the
statements between Sub and End Sub are executed. The syntax for a sub procedure is as follows:- [Private | Public] [Static] Sub Procedurename [(arglist)) [statements] End Sub Arglist is a list of
argument names separated by commas. Each argument acts like a variable in the procedure. There are two types of Sub Procedures namely general procedures and event procedures. (ii) Event
Procedures: An event procedure is a procedure block that contains the control's actual name, an underscore () and the event name. The following syntax represents the event procedure for a
Form Load event. Private Sub Form_Load() ....statement block.. End Sub Event Procedures acquire the declarations as Private by default. (a) General Procedures: A general procedure is declared
when several event procedures perform the same actions. It is a good programming practice to write common statements in a separate procedure (general procedure) and then call them in the
event procedure. (b) Function Procedures: Functions are like sub procedures, except they return a value to the calling procedure. They are especially useful for taking one or more pieces of data,
called arguments and performing some tasks with them. Then the functions returns a value that indicates the results of the tasks complete within the function. (c) Property Procedures: A property
procedure is used to create and manipulate custom properties. It is used to create read only properties for Forms, Standard modules and Class modules. Visual Basic provides three kind of property
procedures-Property Let procedure that sets the value of a property, Property Get procedure that returns the value of a property, and Property Set procedure that sets the references to an object.
Q.28. What is the Menu Editor Dialog Box. What is Popup Menu? Make a Program for Popup Menus. Ans. The Menu Editor is a Visual Basic dialog box that manages menus in your programs.
With the Menu Editor, you can :- [17:28, 20/02/2023] Hi:): Add new menus. Modify and reorder existing menus. .Delete old menus, . Add special effects to your menus, such as access keys, check
marks and keyboard. Shortcuts. Popup Menu: Popup menus are a useful metaphor. Popup menus are sometimes referred to as speed menus, right-click menus, or context menus. Popup
menus are generally invoked by right-clicking the mouse button. Based on the hover location of the mouse, most applications will display a specific menu. The users-focus, or context, determines
which menu is shown hence the name context menu. Visual Basic 6 uses the Menu Editor to create and describe menus. The Menu Editor dialog is used to describe your main menu as well as
menus that will be used as popup or context menus. If you are going to use a menu as a popup menu then set its Visible property to false. When you are ready to show the menu call the
Form.PopupMenu or MDIForm.PopupMenu method. The end result is a feature rich application that shows menus more appropriately displayed in a limited context. Finally I'd like to mention
that this article demonstrates how several techniques can be layered into an application to create a better final product. In this article the Refactoring Extract Method was employed to reuse code
that toggled the visible state of the form. Additionally we were able to combine the popup menu with the system tray example to create a context menu for the system tray icon, yielding a
handsome fit and finish. Q.29. What is Menu Editor in Visual Basic ? Discuss Dialogbox Options in Brief. Ans. Menu Editor utility of VB can be accessed from Tools menu in the forms design
screen. This utility is used for creating menus. It allows you to create custom menus for your application and to define their properties. Dialog Box Options :- (i) Caption: Allows you to enter the
menu or command name that you want to appear on your menu bar or in a menu. If you want to create a separator bar in your menu, you can type a single hyphen (-) in the Caption box. To give
the user keyboard access to a menu item, insert an ampersand (&) before a letter. At run-time, this is [17:28, 20/02/2023] Hi:): underlined (the ampersand is not visible) and the can access the
menu or command by pressing ALT the letter. If you need an ampersand to show in the put two consecutive ampersands in the cap tion. User and menu (ii) Name: Allows you to enter a control
name for the menu item. A control name is an identifier used only to access the menu item in code; it does not appear in a menu. (iii) Index: Allows you to assign a numeric value that determines
the control's position within a control This position is not related to the screen position. (iv) Shortcut: Allows you to select a shortcut key for each command. (v) HelpContextID: Allows you to
assign a unique numeric value for the context ID. This value is used to find the appropriate Help topic in the help file identified by the HelpFile property. (vi) Negotiate Position: Allows you to
select the menu's NegotiatePosition property. This property determines whether and how the menu appears in a container form. (vii) Checked: Allows you to have a check mark appear initially
at the left of a menu item. It is generally used to indicate whether a toggle option is turned on or off. (viii) Enabled: Allows you to select whether you want the menu item to respond to events,
or clear if you want the item to be unavailable and appear dimmed. (ix) Visible: Allows you to have the menu item appear on the menu. (x) WindowsList: Determines if the menu control contains
a list of open MDI child forms in an MDI application. (xi) Right Arrow : Moves the selected menu down one level each time you click it. You can create up to four levels of sub-menus. (xii) Left
Arrow: Moves the selected menu up one level each time you click it. You can create up to four levels of sub - menus. (xiii) Up Arrow : Moves the selected menu item up one position within the
same menu level each time you click it. (xiv) Down Arrow : Moves the selected menu item down one position within the same menu level each time you [17:28, 20/02/2023] Hi:): (xv) Menu List:
A list box that displays a hierarchical list of 49 menu items, Sub-menu items are indented to indicate their hierarchical position of the level. (xvi) Next: Moves selection to the next line. (xvii) Insert:
Inserts a line in the list box above the currently selected line. (xviii) Delete: Deletes the currently selected line. (xix) OK: Closes the Menu Editor and applies all changes to the last form you selected.
The menu is available at design time, but selecting a menu at design time opens the Code windows for that menu's Click event rather than executing any event code. (xx) Cancel : Closes the Menu
Editor and cancels all changes. Q.30. What is Active-X Control? Describe the Advantages and Disadvantages of Active-X Control. Or, What is Active-X Control? How can we Add Active-X Control
into VB Form ? Briefly Define its Component. Ans. Active-X controls are COM components or objects we can insert into a Web page or other application to reuse packaged functionality someone
else has programmed. We can use Active-X controls developed for Visual Basic 6.0 and earlier versions to add features to the Toolbox of Visual Studio. To add Active -X controls to the toolbox :-
(1) On the Tools menu, click Choose Toolbox Items. The Choose Toolbox dialog box appears. (ii) Click the COM Components tab. (iii) Select the check box next to the Active-X control you want
to use and then click OK. The new control appears with the other tools in the Toolbox. (1) We can build three different types of Active-X control in Visual Basic. (ii) We can build an Active-X Control
without using any existing controls, designing our control completely from scratch. (iii) We can build a control that takes a n existing control and extends its functionality. For example validating
data entered into a TextBox. (iv) We can build an Active-X control that is made up of existing controls (Constituent Controls). [17:29, 20/02/2023] Hi:): For example, grouping a Label and a TextBox
to make a cont that provides text input with a read-only prompt. To create an Active-X control, start a new project and selen Active X Control as the project type. We will develop a control called
RGBMixer, so change the Name property to RGBMixer. The first stage is to draw the Constituent Advantages of Active-X Control:- (1). It is customizable and can be easily created. (H) Active-X
Control allows flexible design and is used advanced scripts. (iii) You can easily write up the code in VBA Editor and assign that code to your Active-X control. (iv) It is loaded into the memory
separately. Hence, the program will run smoothly.vi to (v) The user can access the flow of the control programmatically (vi) In this, the user can activate multiple controls. (vii) Active-X controls
are used in day-to-day business activities and save a lot of time. Disadvantages of Active-X Control :- (1) These controls only work for Windows and it is not supported in MAC. Thus, many users
avoid them to use. They are not used for basic and simple scripts. (ii) By default, many computers don't trust Active-X controls and disable them. In that case, the user needs to add the trust
center manually. Component of Active-X Control :- An Active-X control uses several programmatic elements to interact efficiently with a control container and with the user. These are class
ColeControl, a set of event-firing functions and a dispatch map. Every Active-X control object you develop inherits a powerful set of features from its MFC base class, ColeControl. These features
include in-place activation, and Automation logic. ColeControl can provide the control object with the same functionality as an MFC window object, plus the ability to fire events. ColeControl can
also provide windowless controls, which rely on their container for help with some of the functionality a window provides (mouse capture, keyboard focus, scrolling), but offer much faster display.
Q.31. What is Common Dialog Box? Is Form may be Created as Dialog Box, if Yes How? Or, What is Common Dialog Box? Explain Three Common Dialog Box with its Properties. What is
Common Dialog Box? How many Types of Common Or, Dialog Box are there in Visual Basic 6.0? Describe with Suitable Example. Or, What are the Different Types of Built in Dialog Boxes?
Ans. The Common Dialog control provides a standard set of dialog boxes for operations such as opening, saving and printing files, as well as selecting colours and fonts and displaying help. Any
six of the different dialog boxes can be displayed with just one Common Dialog control. A particular dialog box is displayed by using one of the six "Show..." methods of the Common Dialog
Control-ShowOpen, ShowSave, ShowPrinter, ShowColour, ShowFont, or ShowHelp. The Common Dialog Control not an intrinsic control; rather, it is an "Active-X" control that must be added to
the toolbox via the Components dialog box, as shown below. This dialog box is accessed via the Project menu, Components item. Once you check "Microsoft Common Dialog Control 6.0" and click
OK, the control is added to your toolbox (also shown below, circled). Then you can double-click it to make it appear on your form, as you would with any other control. The Common Dialog control
is not visible at run-time. [17:31, 20/02/2023] Hi:): Certain functionality for the dialog boxes is provided automatically by VB and Windows, but other functionality must be coded. For example,
with the Open and Save dialog boxes, the functionality to navigate to different drives and directories is built in, but the functionality to actually save or open a file must be coded in your program.
The following table lists the commonly used dialog box. (1) ColourDialog: The ColourDialog control class represents a common dialog box that displays available colours along with controls that
enable the user to define custom colours. It lets the user select a colour. The main property of the ColourDialog control is Colour, which returns a Colour object. Properties of the ColourDialog
Control: The following are some of the commonly used properties of the ColourDialog control: Properties Allow Full Open Discription Gets or sets a value indicating whether the user can use
the dialog box to define custom colours. AnyColour Gets or sets a value indicating whether the dialog box displays all available colours in the set of basic colours. CanRaiseEvents Gets a value
indicating whether the component can raise an event. CustomColours Gets or sets the set of custom colours shown in FullOpen the dialog box. Gets or sets a value indicating whether the controls
used to create custom colours are visible when the dialog box is opened. [17:32, 20/02/2023] Hi:): (ii) FontDialog: It prompts the user to choose a font from among those installed on the local
computer and lets the user select the font, font size and colour. It returns the Font and C. Properties of the FontDialog Control: The following are some of the commonly used properties of the
FontDialog control :- Property AllowSimulations AllowVectorFonts AllowVertical Fonts Colour Fixed PitchOnly Description Gets or sets a value indicating whether the dialog box allows graphics
device interface (GDI) font simulations. Gets or sets a value indicating whether the dialog box allows vector font selections. Gets or sets a value indicating whether the dialog box displays both
vertical and horizontal fonts, or only horizontal fonts. Gets or sets the selected font colour. Gets or sets a value indicating whether the dialog box allows only the selection of fixed- pitch fonts.
Gets or sets the selected font. Font (iii) OpenFileDialog: The OpenFileDialog control prompts the user to open a file and allows the user to select a file to open. The user can check if the file exists
and then open it. The OpenFileDialog control class inherits from the abstract class FileDialog. If the ShowReadOnly property is set to True, then a read-only check box appears in the dialog box.
You can also set the Read Only Checked property to True, so that the read-only check box appears checked. Properties of the OpenFileDialog Control: The following are some of the commonly
used properties of the OpenFileDialog Control:- Property AddExtension Description Gets or sets a value indicating whether the dialog box automatically adds an extension to a file name if the
user omits the extension. AutoUpgradeEnabled Gets or sets a value indicating whether this FileDialog instance should automatically upgrade appearance and behaviour when running on Windows
Vista. Q.32. What do we mean by Controls? Explain Five Important Controls with their Properties and Events. How we can Setting the Control Properties with the help of Code. What are
Different Types of Control in VB ? Or, Ans. VB Controls: Visual Basic controls and the ways of creating and implementing the. It also helps us to understand the concept of Control Arrays. Controls
are used to receive user input and display output and has its own set of properties, methods and events. Controls properties setting :-Vid A property is a value or characteristic held by a Visual
Basic object, such as Caption or Fore Colour. Properties can be set at design time by using the Properties window or at run-time by using statements in the program code. Object.Property Value
= Where Object is the name of the object you're customizing. Property is the characteristic you want to change. Value is the new property setting. For example, Form1.Caption = "Hello" We
can set any of the form properties using Properties Window. Most of the properties can be set or read during application execution. Visual basic has many control, some of here given below with
their properties and events :- (i) Frame Control: Frame controls are similar to Label controls in that they can serve as captions for those controls that don't have their own. Moreover, Frame
controls can also (and often do) behave [17:32, 20/02/2023] Hi:): as containers and host other controls. In most cases, you only need to drop a Frame control on a form and set its Caption property.
If you want to create a borderless frame, you can set its BorderStyle property to 0-None. Methods Properties Appearance, BackColour, Caption, ClipControls, Container, DragIcon, DragMode,
Enabled, Font, FontBold, FontItalic, FontName, FontSize. (ii) The CheckBox: The Check Box control lets the user selects or unselects an option. When the Check Box is checked, its valu e is set to
1 and when it is unchecked, the value is set to 0. You can include the statements Check1.Value=1 to mark the Check Box and Check1.Value=0 to unmark the Check Box, as well as use them to
initiate certain actions. In checkbox user can select more than one option. Multiple selections are allowed in check box. Properties Alignment, Appearance, BackColour, Caption, Container,
DataChanged, ZOrder. DataField, DataSource, DragIcon, DragMode, Enabled. Events Move, Refresh, ShowWhatsThis, ZOrder. Events Click, DblClick, DragDrop, DragOver, MouseDown,
MouseMove, MouseUp. Methods Refresh, SetFocus, ShowWhatsThis, KeyDown, KeyPress, KeyUp, LostFocus, MouseDown, MouseUp. MouseMove, (iii) Option Button : Option Button controls
are also known as radio buttons because of their shape. You always use Option Button controls in a group of two or more because their purpose is to offer a number of mutually exclusive choices.
Anytime you click on a button in the group, it switches to a selected state and all the other controls in the group become un selected. Its value is set to "True" and when it is unselected; its value
is set to "False". Properties Methods ShowWhatsThis, DragMode, Enabled, Zorder. Alignment, Appearance, BackColour, Caption, Container, DragIcon, Font, FontBold, Font- Italic, FontName,
Font- Size, FontStrikethru (iv) ComboBox: A combobox control is combination of textbox and listbox. This control enables user to select either by typing in the text into combobox or by selecting
items from the list. The function of the Combo Box is also to present a list of items where the user can click and select the items from the list. However, the user needs to dick on the small
arrowhead on the right of the combo box to see the items which are presented in a drop-down list. In order to add items to the list, you can also use the AddItem method. Combobox is collapsed
and it does not displays all the items. Properties Methods NewIndex, MousePointer, ListCount, Enabled, Style. AddItem, Clear, RemoveItem, SetFocus. Events Change, DropDown, LostFocus,
GotFocus. (v) The PictureBox Control: PictureBox controls are among the most powerful and complex items in the Visual Basic Toolbox Window. In a sense, these controls are more similar to
forms than to other controls. For example, PictureBox controls support all the properties related to graphic output. Properties Align, Appearance, AutoRedraw, AutoSize, BackColour, BorderStyle,
ClipControls, Container, CurrentX, CurrentY, DataChanged, DataField, DataSource, DragIcon. Methods Drag, Line, LinkPoke, LinkExecute, LinkRequest, Refresh, Scale. Events Click, DblClick,
Resize, DragDrop, DragOver, GotFocus, KeyDown, KeyPress, KeyUp, LinkClose. LinkSend, Point, Print, PSet, Q.33. Explain the Method for Working with the Properties Windows, Scale Properties
and Colour Properties. Ans. All controls in Visual Basic IDE have properties. By altering the properties of a control, we are able to customize its appearance and how it resp onds to an event.
Basically, we can set the properties of the controls in the properties window of Visual Basic IDE at design time or at run-time. Figure 3.1 is the typical properties window for a form. In the Properties
Window, the item appears at the top part is the object currently selected (in Figure 1, the object selected is Form1). At the bottom part, the items listed in the left column represent the the items
listed in the right column represent the states of the thames of various properties associated with the selected object while properties. Properties can be set by highlighting the items in the right
column then change them by typing or selecting the options available. [17:33, 20/02/2023] Hi:): We may also alter other properties of a control such as font, location, size, foreground colour,
background colour, MaximizeBox, MinimizeBox and etc. we can also change the properties of the object at run-time to give special effects such as change of colour, shape, animation effect and
so on. Properter Farm Tyten wdows.Forms Form Accessbeame Accesible le badgroundlinage Backgroundnagelarat Te Cursor a Control (none) Defaut Mcrosoft Sans Serif, 0.25p Controffe
Sitable False Addition Calculator. Text The test associated with the control False We can customize a form by changing the values in the properties window. First of all, let's change the title of
the form. The title of the form is defined by the Text property and its default name is Form 1. To change the form's title to any name that you like, simply click in the box on the right of the Text
property and type in the new name, in this example, the title is Addition Calculator. After this, you can notice that the form's title will appear on top of the windows. In addition, we can customize
the form's colour. The following code will change the form colour to yellow every time the form is loaded. Visual Basic 2012 uses RGB(Red, Green, Blue) to determine the colours. The RGB code
for yellow is 255,255,0; while Me in the code refer to the current form and Backcolour is the property of the form's backgrou nd colour. The formula to assign the RGB colour to the form is
Colour.FormArbg(RGB code). The event procedure is as follows:- Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.BackColour Colour.FromArgb(255, 0, 255) End Sub End Class Q.34. What is Validation? Explain Different Types of Validation. Ans. Validation is an important part of any computer application
that requires user interaction. In its broadest sense, the concept applies to anything that the application does to ensure th at data entered by the user is acceptable for the purposes of the
application. Validation can take place at various times in the data entry cycle. For example, the programmer can :- (1) Constrain the user's entry of data before it begins by providing very restricted
data input fields that permit only valid choices. The most common way to do this is to provide standard controls that do not p ermit free keyboard entry, such as drop-down lists, option buttons
and check boxes. (ii) Constrain the user's entry of data at the moment that it occurs by monitoring every keystroke for validity and rejecting unwanted input as it's typed. For instance, a particular
entry field might seem to the user to ignore anything but numeric characters. (iii) React to the user's entry of data after the user is finished, accepting or rejecting the contents of a data field
when the user attempts to leave the field or close the screen. Input validation can also have varying degrees of user participation. For instance, the program can:- (i) Automatically correct a user's
mistakes without asking the user's opinion. (11) Warn the user of incorrect input and prompt the user to correct the input before allowing the user to continue with other activities. The first
objective for validation, verifying data entered by a user at the field level and the form level, deals mostly with the immediate validation of user input from the keyboard. In order to cover this
objective, we discuss the three main Keystroke events, KeyUp, KeyDown and KeyPress. These events can fire at the level of individual controls and also at the level of the form, thus allowing two
levels of validation. An application also usually validates field-level data when the user finishes entry in each field and attempts to leave the field by setting focus away from it. Validation can be
simple or complex, depending upon the way it is performed. For example, validating e-mail address or phone numbers is easy. On the other hand, checking different data fields for consistency
and accuracy in a master database will be complex. In a nutshell, [17:34, 20/02/2023] Hi:): data needs to be validated at the same stage/level where it's most likely to be erroneous. Following is
the description of different types of data validation techniques :- (i) Form Level Validation: It ensures that all the fields marked as mandatory in the web form are filled correctly before the user
clicks the submit button on the page. (ii) Field Level Validation: It makes certain that users enter correct value across a specific data field. For example, "Name" Field can't have a numeric value,
and "e-mail" field should contain a value having "." and "@". (iii) Data Saving Validation: Data saving validation is used for multiple data entry forms and option screens. User is allowed to save
data on any or all tabs/pages before leaving the page. (iv) Search Criteria Validation : This type of validation is used when there are multiple search criteria in a form and user wants to save the
search results before navigating to a different page. (v) Range Validation: This validation type is used to make sure that the numeric value, characters or date entered is within the specific range
Data validation authenticates the data for duplicate information, incorrect formats, types, grammatical and punctuation errors. It is an effective technique to keep the data up-to-date and
accurate. Q.35. What is Variable? How can we Declare Variable in Visual Basic. Or, What do we Understand by Variable? How is it Declared? What do we Mean by Scope of Variable? Ans.
Variables: Variables are the memory locations which are used to store values temporarily. A defined naming strategy has to be followed while naming a variable. A variable name must begin with
an alphabet letter and should not exceed 255 characters. It must be unique within the same scope. It should not contain any special character like %, &, !, #, @ o r $. The following are the rules
when naming the variables in Visual Basic:- It must be less than 255 characters. No spacing is allowed. It must not begin with a number. [17:34, 20/02/2023] Hi:): Cannot use exclamation
mark (1), or the characters @, &, $, #. . Cannot repeat names within the same level of scope. Examples of Valid and Invalid Variable Names :- Valid Name My Car Invalid Name My.Car this year
1NewBoy He&HisFather & is not acceptable. Long_Name_Can_beUSE Declaration of Variable :- There are many ways of declaring variables in Visual Basic. Depending on where the variables are
declared and how they are declared, we can determine how they can be used by our application. The different ways of declaring variables in Visual Basic are listed below:- (i) Explicit Declaration
: Declaring a variable tells Visual Basic to reserve space in memory. It is not must that a variable should be declared before using it. Automatically whenever Visual Basic encounters a new variable,
it assigns the default variable type and value. This is called implicit declaration. Though this type of declaration is easier for the user, to have more control over the variables, it is advisable to
declare them explicitly. The variables are declared with a Dim statement to name the variable and its type. The As type clause in the Dim statement allows to define the data type or object type
of the variable. This is called explicit declaration. Syntax : Dim VariableName As DataType For example, Dim strName As String Dim intCounter As Integer (ii) Using Option Explicit Statement: It
may be convenient to declare variables implicitly, but it can lead to errors that may not be recognized at run-time. Say, for example a variable by name intcount is used implicitly and is assigned
to a value. In the next step, 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. This is because the intcount variable has been mistyped as intcount in the right hand side of the second variable. But Visual Basic does not see this as a mistake and
considers it to be new variable and therefore gives a wrong result. In Visual Basic, to prevent errors of this nature, we Q.36. What do you understand by Scope of Variable? Discuss Various Scopes
of Variable in Visual Basic. Ans. Scope of Variables :- A variable is scoped to a procedure-level (local) or module- level variable depending on how it is declared. The scope of a variable, procedure
or object determines which part of the code in our application are aware of the variable's existence. A variable is declared in general declaration section of e-Form and hence is available to all the
procedures. Type of Scope of Variable :- (i) Local Variables: A local variable is one that is declared inside a procedure. This variable is only available to the code inside the procedure and can be
declared using the Dim statements as given below:- Dim sum As Integer The local variables exist as long as the procedure in which they are declared, is executing. Once a procedure is executed,
the values of its local variables are lost and the memory used by these variables is freed and can be reclaimed. Variables that are declared with keyword Dim exist only as long as the procedure is
being executed. (ii) Static Variables: Static variables are not re-initialized each time Visual Invokes a procedure and therefore retains or preserves value even when a procedure ends. In case we
need to keep track of the number of times a command button in an application is clicked, a static counter variable has to be declared. These static variables are also ideal for making controls
alternately visible or invisible. A static variable is declared as given below:- Static intPermanent As Integer [17:35, 20/02/2023] Hi:): Variables have a lifetime in addition to scope. The values in a
63 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 value of a local variable can be preserved using the Static Keyword. The following procedure calculates the running total by adding new values to the previous values stored
in the static variable value :- Function Running Total () Static Accumulate Accumulate Running Total End Function Accumulate + num =Accumulate If the Variable Accumulate was declared with
Dim instead of static, the previously accumulated values would not be preserved across calls to the procedure and the procedure would return the same value with which it was called. To make
all variables in a procedure static, the Static Keyword is placed at the beginning of the procedure heading as given in the below statement: Static Function Running Total () (iii) Module Level
Variables: A module level variable is available to all the procedures in the module. They are declared using the Public or the Private keyword. If you declare a variable using a Private or a Dim
statement in the declaration section of a module-a standard BAS module, a form module, a class module and so on-you're creating a private module-level variable. Such variables are visible only
from within the module they belong to and can't be accessed from the outside. In general, these variables are useful for sharing data among procedures in the same module :- 'In the declarative
section of any module Private Login Time As Date' A private module-level variable Dim Login Password As String Another private module-level variable. We can also use the Public attribute for
module-level variables, for all module types except BAS modules. (Public variables in BAS modules are global variables.) In this case, 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. In this case, however, it's more appropriate to describe such a variable
as a property'. Q.37. What is Module ? Discuss Form Module, Standard Module and Class Module with Example. Ans. Modules: Code in Visual Basic is stored in the form of Modules. The three
kind of modules are Form Modules, Modules and Class Modules. A simple application may contain a singl Form, and the code resides in that Form Module itself. As the application grows, additional
Forms are added and there may be a common code to be executed in several Forms. To avoid the duplication d code, a separate module containing a procedure is created tha implements the
common code. This is a Standard Module. Class Module (.CLS filename extension) are the foundation of the object oriented programming in Visual Basic. New objects can be created by writing
code in class modules. Each module can contain :- DLL procedure declarations. (i) Declarations: May include constant, type, variable and (ii) Procedures: A sub function, or property procedure
that contain pieces of code that can be executed as a unit. These are the rules to follow when naming elements in VB. variables, constants, controls, procedures, and so on :- (1) A name must
begin with a letter. (ii) May be as much as 255 characters long (but don't forget that somebody has to type the stuff!). (iii) Must not contain a space or an embedded period or type. declaration
characters used to specify a data type; these are ! # % $ & @. (iv) Must not be a reserved word (that is part of the code, like Option, for example)\]]]]]. (v) The dash, although legal, should be
avoided because it may be confused with the minus sign. Instead of First-name use First_name or FirstName. Q.38. Discuss Select Case Structure with Example? Ans. Select...Case Selection
Structure: The Select Case structure compares one expression to different values. The advantage of the Select Case statement over multiple If...Then... Else statements, is that it makes the code
easier to read and maintain. The Seled Case structure tests a single expression, which is evaluated once at the top of the structure. The result of the test is then compared with several values, and
if it matches one of them, the corresponding block of statements is executed. Here's the syntax of the Select Case statement. The following program block illustrate the working Select...Case :-
Syntax of the Select...Case selection structure Select Case expression [17:35, 20/02/2023] Hi:): Case value1 Statements Case value2 Statements Case valuen Statements Case else statements
End Select e.g.: Assume you have to find the grade using select...case and display I the text box Dim average as Integer average = txtAverage.Text Select Case average Case 100 To 75 txtGrade.Text
= "A" Case 74 To 65 txtGrade. Text="B" Case 64 To 55 txtGrade. Text="C" Case 54 To 45 txtGrade. Text="S" Case 44 To 0 txtGrade.Text = "F" Case Else MsgBox " Invalid average marks" End
Select Q.39. Explain For...Next and For Each.... Next Loop Structure. Or, Give the Syntax for Next Loop. Explain with Example. Ans. For....Next Loop: The syntax is :- For counter = Start To End
Step [Increment] One or more VB statements Next [counter] The arguments counter, start, end, and increment are all numeric. The increment argument can be either positive or negative. If
increment is positive, start must be less than or equal to end or the statements in the loop will not execute. If increment is negative, start must be greater than or equal to end for the body of the
loop to execute. If steps aren't set, then increment defaults to 1. [17:36, 20/02/2023] Hi:): In executing the For loop, visual basic:- (1) Sets counter equal to start. (ii) Tests to see if counter is
greater than end. If so, visual basic exits the loop (if increment is negative, visual basic tests to see if counter is less than end). (iv) Increments counter by 1 or by increment, if it's specified. (iii)
Executes the statements. (v) Repeats steps 2 through 4. The For Each...Next: Construction runs a set of statements once for each element in a collection. We specify the loop control variable,
but we do not have to determine starting or ending values for it. Repeats a group of statements for each element in a collection. Syntax :- VBCopy For Each element [ As datatype ] In group [
statements ] [Continue For ] [ statements ] [Exit For ] [statements ] Next [element] Parts:- Q.4 Or, stan mer Term Element of r appl Definition Required in the For Each statement. Optional
in the Next statement. Variable. Used to iterate through the elements of the collection. Optional if Option Infer is on (the default) or ele- ment is already declared; required if Option Infer is off
and element isn't already declared. The data type of element. in Datatype with Men Group The sele Statements Continue For Required. A variable with a type that's a collection type or
Object. Refers to the collection over which the statements are to be repeated. Optional. One or more statements between For Each and Next that run on each item in group. Optional. Transfers
control to the start of the For Each loop. Optional. Transfers control out of the For Each loop. Required. Terminates the definition of the For Each loop. [17:36, 20/02/2023] Hi:): While... Wend
Statement: A While...Wend statement behaves like the Do While...Loop statement. Syntax: While condition Statements Wend. Example : The following While...Wend counts from 1 to 100 Dim
number As Integer number 1 While number <=100 number number + 1 Wend Q.40. Discuss the Menu Editor. How to Create Menu? Explain Menu Naming Conventions. Or, What is Menu?
Which Type of Menu is Supported by Visual Basic? Explain with Example. Ans. Menu: The menu is a bar at the top of the form. The standard form is display without menu, but the user can add
it. This menu could be included in form or MDI using menu editor. Menu Editor: To use menu there are four ways:- (1) Press menu icon from toolbar. (ii) Press (ctrl+E) from key board. (iii) Click
on tools>Menu Editor. (iv) Right Click on Form or MDI form Menu editor box appears. Creating Menus in VB Menus Windows applications provide groups of related commands in menus. These
commands depend on the application, but some-such as Open and Save-are frequently found in applications. Visual Basic provides an easy way to create menus with the modal Menu Editor
Dialog. The dialog is displayed when Menu Editor is selected from the tools menu. The menu editor command is grayed unless the form is visible. The menu dialog can also be displayed by right-
clicking the form and selecting menu editor. The menu editor dialog, shown in figure, contains the Textboxes Caption and Name. The value entered in the Caption Textbox is the the name the
user sees. The value entered in the Name Textbox is the variable name the programmer uses. Every menu must have a Caption and a Name. Menus are like other controls in that they have
properties and events. The menu editor is a way of setting select properties for a menu. Once a menu is created, its properties can be viewed in the properties [17:36, 20/02/2023] Hi:): can create
menu control arrays. The Index Textbox specifies the menu's index in the control array. Menus that are not top level menus can have shortcut keys (combinations of Ctrl, Shift and letter keys).
Shortcut keys are specified using the Shortcut ComboBox. All shortcut keys listed in the shortcut ComboBox are predefined by visual basic. Each using menu item has four properties associated
with it. These properties can be set at design time using the Menu Editor or at run-time the standard dot notation. These properties are:- (1) Checked Used to indicate whether a toggle option
is turned on or off. If True, a check mark appears next to the menu item. (11) Enabled If True, menu item can be selected. If False, menu item is grayed and cannot be selected. (iii) Visible Controls,
whether the menu item appears in the structure. (iv) WindowList Used with Multiple Document Interface (MDI). At the bottom of the Menu Editor Form is a list box displaying the hierarchical
list of menu items. Sub-menu items are indented to their level in the hierarchy. The right and left arrows adjust the levels of menu items, while the up and down arrows move items within the
same level. The Next, Insert and Delete buttons are used to move the selection down one line, insert a line above the current selection, or delete the current selection, respectively. Q.41. Discuss
briefly the Graphics Control. Ans. We place graphics on three controls in Visual basic :- • Form • PictureBox • ImageBox The main difference in these three controls is that the ImageBox control
is designed specifically for displaying images and not for creating new images or manipulating them. The other two controls provide drawing methods that let we design graphics at run-time. The
methods for loading graphics on the various controls are simpler than creating graphics from scratch. We can place graphics on controls-at design time and run-time. To load a graphic (bitmap or
icon) on a control at design time, you assign its filename to the Picture property of the control in the Properties window. This same procedure can't change the image displayed at run-time;
instead, we must use the LoadPicture0 function, which is described shortly. If the graphic is assigned [17:36, 20/02/2023] Hi:): the files that the Visual Basic Editor generates for each Form in a
project has the extension FRX.This is where the image (the actual bitmap) is stored. As a consequence, the size of the application will increase if its Forms contain bitmaps that must be loaded at
run- time. The alternative is to load the graphic at run-time with the LoadPicture0 function. This reduces the size of the fRX file, but your application must make sure the file is available at run-
time. Vector drawings aren't loaded, they are generated on the fly. Sizing Image: When an linage is loaded on a Form or a PictureBox, you must make sure it will fill the available space, unless you
let the user select the graphic at run-time. Graphics are usually placed on ImageBox or Picture Box Controls. The ImageBox is good for displaying graphics and uses fewer resources than PictureBox
Controls. The Picture Box Control provides methods for drawing at runtime and is much more flexible than the Image.Box Control. As a consequence, the PictureBox Control uses more resources.
Each control provides a different property for controlling the appearance of the picture displayed The ImageBox Control: If the Stretch Property is True, the image is resized to fill the area of the
ImageBox Control. Unless the ~ontrol's dimensions have the same aspect ratio as the image's dimensions, the image is distorted as it's resized. If the Stretch Property is False, the ImageBox Control
behaves like a PictureBox with its Aut6Size property set to True. Figure 6.3 shows two ImageBox Controls, both containing the same linage. Notice how the image is resized in the ImageBox Control
whose Stretch Property is True. The PictureBox Control: If the AutoSize Property is True, the control is resized to the dimensions of the image it contains. If the AutoSize Property is False, only the
part of the image that can fit on the control is displayed. Loading and Saving Images: To load a graphic on a control at run-time, use the LoadPicture method as follows:- Forml.Picture LoadPicture
(fileName) The fileName variable is 'the name of the file containing the graphic'. This file can have one of the following extensions : - BMP Bitmap. • GIF Graphics Interchange Format. Joipt
Photographic Experts Group. .JPG • DIB Device Independent Bitmap. SavePicture Picture, Filename: The picture argument is the Picture property [17:37, 20/02/2023] Hi:): Q.42. Explain the Run
Mode, Design Mode and Break Mode of Visual Basic. Ans. The VBA IDE can be in any one of three modes-run mode, break mode or design mode. The IDE is in design mode, when you are writing
code or designing a form. Run mode occurs when a procedure is running. To run (or execute) a procedure, just place the cursor anywhere within the procedure code and hit the F5 key (or select
Run from the Run menu). If a running procedure seems to be hanging, you can usually stop the procedure by hitting Ctrl-Break (hold down the Control key and hit the Break key). Break mode is
entered when a running procedure stops because of either an error in the code or a deliberate act on your part (described later in this chapter). In particular, if an error occurs, Word will stop
execution and display an Error dialog boxes offer a few options; end the procedure, get help (such as it may be) with the problem, or enter break mode to debug the code. In the latter case, Word
will stop execution of the procedure at the offending code and highlight that code in yellow. Aside from encountering an error, there are several ways we can deliberately enter break mode for
debugging purposes: (1) Hit Ctrl-Break and choose Debug from the resulting dialog box. (ii) Include a Stop statement in the code, which causes Word to enter break mode. (iii) Insert a breakpoint
on an existing line of executable code. This is done by placing the cursor on that line and hitting the F9 key (or using the Debug menu). Word will place a red dot in the left margin in front of that
line and will stop execution when it reaches the line. You may enter more than one breakpoint in a procedure. This is generally preferred to using the Stop statement, because breakpoints are
automatically removed when you close down the Visual Basic Editor, so you don't need to remember to remove them, as you do with Stop Statements. [17:37, 20/02/2023] Hi:): (iv) Set a watch
statement that causes Word to enter break mode if a certain condition becomes true. (I discuss watch expressions later in this chapter.) To exit from break mode, choose Reset from the Run
menu. The caption in the titlebar of the VBA IDE indicates which mode is currently active. In particular, the caption contains the word "[running]" when in run mode and "[break]" when in break
mode. Q.43. What is ODBC? How Can we Create the ODBC in Visual Basic ? Ans. Open Database Connectivity (ODBC) is an open standard Application Programming Interface (API) for accessing
a database. By using ODBC statements in a program, you can access files in a number of different common databases. In addition to the ODBC software, a separate module or driver is needed for
each database to be accessed. Open Database Connectivity (ODBC) is an open standard application programming interface (API) that allows application programmers to access any database. The
main proponent and supplier of ODBC programming support is Microsoft, but ODBC is based on and closely aligned with The Open Group standard Structured Query Language (SQL) Call-Level
Interface (CLI). The Open Group is sponsored by many major vendors, including Oracle, IBM and Hewlett Packard Enterprise, and this consortium develops and manufactures The Open Group
Architecture Framework (TOGAF). In addition to CLI specifications from The Open Group, ODBC also aligns with the ISO/IEC for data base APIs. How ODBC Works :- ODBC consists of four
components, working together to enable functions. ODBC allows programs to use SQL requests that access databases without knowing the proprietary interfaces to the databases. ODBC handles
the SQL request and converts it into a request each database system. The four different components of ODBC are:- (i) Application: Processes and calls the ODBC functions and submits the SQL
statements; (ii) Driver Manager: Loads drivers for each application; (iii) Driver: Handles ODBC function calls and then submits each SQL request to a data source; and (iv) Data source: The data
being accessed and its database management system (DBMS) OS. When you want to connect DB in Visual Basic Project, there are many components available for this process. But, here we use
ADODC (ADO Data Control) component for connectivity. [17:37, 20/02/2023] Hi:): You have to discover connection string. For this string process, right click on ADODC and select "ADODC
Properties". Click on "Build..." button from "Use Connection String" option, OLE DB Provider for ODBC Drivers" Option from it, then press This will present "Data Link Properties" box. Select
"Microsoft "Next>>" button. This process will switch on "Connection" Tab. Expand "Use data source name" combo box and this will present data source name including your created Data Source
Name. Select your created Data Source Name such as "MYDataSource". ( Then click on "Test Connection" Button. This will show mes sage saying "Test connection succeeded". After that press
"OK" Button. Now, you will see, there is string will be present in "Use Connection String" text box. Copy this string for further connectivity process. given Align Back Enab Font Bord Cont
Q.44. Explain Textbox, Label and Command Button with their Properties, Methods and Events. Ans. Controls are used to receive user input and display output and has its own set of properties,
methods and events. Here we discuss three important controls:- (i) Textbox: The TextBox is like a Label but, it is used to input data into the program. The data typed in is in the Text property of
the control. TextBox controls offer a natural way for users to enter a value in your program. For this reason, they tend to be the most frequently used controls in the majority of Windows
applications. TextBox controls, which have a great many properties and events, are also among the most complex intrinsic controls. Some Important properties methods and events of test box
controls are:- Data Data most an ill most event Properties/Methods Enabled Events Index Change Click Butto Locked Pro GotFocus Multiline App Bac LostFocus ScrollBars KeyUp (ii)
Label Control: The label is a very useful control for Visual Basic, as it is not only used to provide instructions and guides to the users, it can also be used to display outputs. One of its most important
[17:38, 20/02/2023] Hi:): properties is Caption. Using the syntax Label.Caption, it can display text and numeric data. You can change its caption in the properties window and also at run-time.
soft ess Important Properties of Label Control :- (a) Caption: The text that is displayed in Jse arce ted the label. (b) BackColour and ForeColour: Colours of the background (c) BackStyle: Opaque
or Transparent - whether the background and the text. is visible or not. (d) Font: Font and size of text. (e) Alignment: Text centered, left or right. Some other Properties, Method and Events of
Label Control are given below:- es K se ner Events eir Property Method Alignment, Appearance LinkRequest, BackColour, BackStyle Move Enabled, Font Refresh FontBold, FontItalic
ShowWhatsThis Zorder Drag BorderStyle, Caption Container LinkExecute DataChanged, DataSource, DataField LinkPoke Change Click, DblClick DragDrop, DragOver LinkClose ut LinkError
LinkNotify பர் MouseDown, MouseMove X (iii) Command Button: The command button is one of the most important controls as it is used to execute commands. It displays an illusion that the
button is pressed when the user click on it. The most common event associated with the command button is the Click event and the syntax for the procedure is :- Private Sub Command1_Click()
Statements End Sub Some Important Properties, Method and Events of Command Button are:- x Methods Events ZOrder Properties Appearance BackColour, FontBold Cancel, Enabled
Caption, Container Default, DragIcon ShowWhatsThis DragDrop, DragOver KeyDown KeyPress, KeyUp LostFocus SetFocus Refresh Move, Drag MouseMove, MouseUp [17:38, 20/02/2023]
Hi:): Q.45. Explain Control Array with Example. Or, What are the Advantages of Using Control Arrays in VB ? Ans. A control array is a group of controls that share the same name type and the
same event procedures. Adding controls with control arrays uses fewer resources than adding multiple control of same type at design time. A control array can be created only at design time and
at the very minimum at least one control must belong to it. We create a control array following one of these three methods :- (a) We create a control and then assign a numeric, non-negative
value to its Index Property; we have thus created a contro array with just one element. (b) We create two controls of the same class and assign them an identical Name Property. Visual Basic
shows a dialog box warning us that there's already a control with that name and asks whether we want to create a control array. Click on the Yes button. (c) We select a control on the form, press
Ctrl+C to copy it to the clipboard and then press Ctrl+V to paste a new instance of the control, which has the same Name Prop erty as the original one. Visual Basic shows the warning mentioned
in the previous bullet. Advantages of Control Array :- (1) Controls that belong to the same control array share the same set of event procedures; this often dramatically reduces the amount of
code we have to write to respond to a user's actions. (ii) We can dynamically add new elements to a control array at run-time; in other words, we can effectively create new controls that didn't
exist at design time. (iii) Elements of control arrays consume fewer resources than regular controls and tend to produce smaller executables. Besid es, Visual Basic forms can host up to 256
different control names, but a control array counts as one against this number. In other words, control arrays let you effectively overcome this limit. (iv) Control arrays are especially useful with
menus because arrays offer a solution to the proliferation of menu Click events and, above all, permit you to create new menus at run-time. [17:38, 20/02/2023] Hi:): Q.46. Explain the Procedure
Sub-routine and Functions Arguments of VB Language. Ans. Sub-routines can be thought of as miniature programs. A sub-routine has a name attributed with it, much like a variable does. Unlike
a variable, a sub-routine doesn't hold data. Instead, it holds code. When the code in a sub-routine is executed, the sub- routine is said to be "called". Therefore, one sub-routine can "call" another
sub-routine. Some sub-routines are called automatically when certain actions are performed. For example, the Form Load sub- routine is automatically called when a form loads. This is where
you have been inserting your test code before. What you were actually doing was adding code to this sub-routine. Use of Sub-routine: Sub-routines are useful because they eliminate redundancy.
Consider a complicated program like a word processor. When certain actions are performed, such as closing the program, opening a file or closing an individual file, the word processor would
probably check to see if you had modified your document. If the user had modified the document since they opened it, the user would be prompted to save the file before performing the action.
You could imagine that checking if the document was modified, prompting the user and acting on the input would require many lines of code. If the programmer had literally typed this code into
all of the places in the program where this check was to be made, it would still work fine. However, what would happen if the way the program handles documents changed and therefore this
code needed to be changed? The programmer would have to change the code in every place where this check was made. Even worse, what if the programmer changed the code in a few places
but not in another? This would lead to bugs that are difficult to track down. Instead, if this code was put in a subroutine, the sub-routine would simply be called from all of these places. If the code
then needed to be changed, the programmer would only have to change it in one place; inside the sub-routine. By doing this, sub-routines eliminate redundant code, making the entire program
easier to manage. Functions: Functions are basically the exact same as sub- routines, except that they return a value. That means that the function itself has a type and the function will return a
value to the calling sub-routine based on the code that it contains. An example of this would be a function that adds two numbers, shown below. A function is declared the exact same way as a
sub-routine, except using the "Function" keyword instead of "Sub". To return a value, assign a value of [17:38, 20/02/2023] Hi:): Q.47. Discuss the Menu Editor. How to Create Menu? Explain
Menu Naming Convention. Ans. Menu Control: An application menu system is constructed from menu controls. Each menu name, menu command and separator bar is a separate control. When
we create menu controls, we name them with MNU prefix. We placed the text we went to displayed by a menu control is its caption properties. As with other controls, acces s keys are assigned
by an ampersand sign in the caption properties before the character that is to because the access key. The names d the controls that are the commands of the menu. Write other controls in visual
basic, menu controls have properties and respond to events We make a menu functional by writing click event procedure for the control. Menu Editor: We create menu control with menu editor.
We start menu editor with one of the following action :- (a) Click the menu editor button from the standard toolbar. Or (b) Click tools menu from menu bar then click on menu editor option from
tools menu. Or (c) Press CTRL+E, in all cases, a menu editor dialog box will open. This dialog box divided into two parts vertically. First part contains, caption, name, index, shortcut, help contest
id, negotiate position text boxes and list boxes and it also contains four check boxes such as checked, enable, visible and window list. There are menu command button also available in this area
for different operation. Second help portion of the dialog box displayed as empty. When user choose menu name, menu command, such command, etc., it appear on this area. Here are description
of the field that we will used in this text. (i) Caption: A caption is used for menu name which is displayed in the menu list. We can assign an ampersand sign before a ch aracter in the caption. If
we want the control to be a separator bar, the caption should be sets to a hyphen (-). (ii) Name: The name text box is used to assign a name of menu, menu command, sub-menu and show on.
We can use only this name in visual basic program. Normally name can be prefix with MNU. Type the name of the menu control in this field. (iii) Shortcut: A shortcut is dropdown list box. When
we click on dropdown arrow, a list of shortcut name are displayed on dialog box. Select any one shortcut key out of multiple option [17:39, 20/02/2023] Hi:): (iii) Down arrow: When we click this
button the selected menu control moves down one position in the list. (iv) Up arrow: When we click this button the selected menu control moves up one position in the list. (v) Next: When we
click this button the control below the currently selected control becomes the selected control. (vi) Insert: When we click this button a new menu control is inserted into the menu system directly
above the currently selected control. (vii) Delete : When we click this button the selected menu control is deleted. Q.48. Write about the Difference between While and Do-While Structure.
Ans. Iteration statements allow the set of instructions to execute repeatedly till the condition doesn't turn out false. [17:39, 20/02/2023] Hi:): Here, the main difference between a while loop and
do loop is that while loop check condition before iteration of the On the other hand, the do-while loop verifies the condition a execution of the statements inside the loop. Furthermore, the
while loop is known as the entry-contr loop. Conversely, the do-while loop is called the exit controlled y Basis for Comparison General Form While Do-While do{ while (condition) statements;
//body of loop statements; //body of while(Condition); In 'do-while loop the controlling condition appears at the end of the loop. Controlling In 'while' loop the Condition Iterations controlling
condition appears at the start of the loop. The iterations do not occur if, the condition at the first iteration, appears false. The iteration occurs least once even if the condition is false at the first
iteration. Alternate name Semi-colon Entry-controlled loop. Exit-controlled loop. Not used. Used at the end of the lo after cann does char acce writ with are Q.1 infe ed Ba Q.49. Explain
Frontend and Backend Tools. Ans. Frontend and Backend are the two most popular terms used in web development. These terms are very crucial f Application development but are quite different
from each other Each side needs to communicate and operate effectively with the other as a single unit to improve the websites functionality. Term the front end is referred to as the 'client side
of the application. It includes everything that users experience directly text colours and styles, images, graphs and tables, buttons, colour and navigation menu. The structure, design, behavior
and content of everything see on browser screens when websites, web applications, or mobile apps are opened up, is implemented by front End developers Responsiveness and performance are
two main objectives of the Front End. Backend is the server-side of the website. It stores and arranges data and also makes sure everything on the client-side of the website works fine. It is the
part of the website [17:39, 20/02/2023] Hi:): cannot see and interact with. It is the portion of software that does not come in direct contact with the users. The parts and characteristics developed
by backend designers are indirectly accessed by users through a front-end application. Activities, like writing APIs, creating libraries and working with system components without user interfaces
or even systems of scientific programming, are also included in the backend.

You might also like