VBA (Visual Basic for Applications) Interview Questions And Answers
Download VBA Interview Questions and Answers PDF
Strengthen your VBA interview skills with our collection of 39 important questions. These questions will test your expertise and readiness for any VBA interview scenario. Ideal for candidates of all levels, this collection is a must-have for your study plan. Download the free PDF now to get all 39 questions and ensure you're well-prepared for your VBA interview. This resource is perfect for in-depth preparation and boosting your confidence.
39 VBA Questions and Answers:
VBA Job Interview Questions Table of Contents:
1 :: Explain What are the ADO objects?
The ADO objects are:
Command
Connection
Error
Field
Parameter
Property
Record
RecordSet
Stream
Connection: Used to make a connection between your app and an external data source, i.e., sql server. Command: Used to build queries, including user-specific parameters, to access records from a data source (which are returned in a Recordset) Recordset: Used to access records returned from an SQL query. With a recordset, you can navigate returned records. You can also add, modify or delete records.
Read MoreCommand
Connection
Error
Field
Parameter
Property
Record
RecordSet
Stream
Connection: Used to make a connection between your app and an external data source, i.e., sql server. Command: Used to build queries, including user-specific parameters, to access records from a data source (which are returned in a Recordset) Recordset: Used to access records returned from an SQL query. With a recordset, you can navigate returned records. You can also add, modify or delete records.
2 :: Explain the difference between Msgbox Statement and MsgboxQ function?
MsgBox is a built in VB function which displays a Message Box and MsgBoxQ is a function defined by the user.
Read More3 :: Explain Which controls can not be placed in MDI?
The Controls which do not have Align property can't be placed on MDI Form.
E.g., Picturebox only has Align property in Standard Components of VB other controls dont have align property an hence can't be drawn on MDI Form.
Timer control can also be placed on MDI form.
Read MoreE.g., Picturebox only has Align property in Standard Components of VB other controls dont have align property an hence can't be drawn on MDI Form.
Timer control can also be placed on MDI form.
4 :: Explain the difference between visual basic, VB script and visual basic applications?
Visual basic is useful if you are planning to develop your programs from scratch. This language helps you in developing Active x controls, exe files, etc.
Visual script is a powerful tool, through which you can create small scale applications on web pages, automation applications, etc. Integrated development environment is not present for VB script.
Visual basic applications are very useful in automating your existing application. VB application is useful for developing already existing applications.
Read MoreVisual script is a powerful tool, through which you can create small scale applications on web pages, automation applications, etc. Integrated development environment is not present for VB script.
Visual basic applications are very useful in automating your existing application. VB application is useful for developing already existing applications.
5 :: How to format expressions by using VBA?
Format functions can be used to format many of the expressions such as currency, time, date, percentages and numbers. These functions are much simpler to use in VBA. User defined date, numeric and string formats are present in many of the applications.
Read More6 :: What is insert module and Goal Seek functions present in VBA?
The chief use of VBA is to make use of its special function which helps in repeated actions. Goal seek function helps to reduce manual entry of the code each and every time. This solves the problem of repeated function entry by automating functions and actions. Sub routines are inserted into the using the VBA editor and command insert module.
Read More7 :: Explain four different cursor and locking types in ADO and describe them briefly?
Cursor types:1. Forwardonly, 2. Static, 3. Keyset 4. Dyanmic
Lock types : 1. lockpessimistic, 2. lockoptimistic,3. lockbatchoptimistic 4. lockreadonly
Read MoreLock types : 1. lockpessimistic, 2. lockoptimistic,3. lockbatchoptimistic 4. lockreadonly
8 :: Explain Which controls have refresh method, clear method?
Datagrid,listbox,combobox,label,button have refresh methodand textbox has clear methodalmost all controls have refresh method
Read More9 :: What is pointers function?
Visual basic applications have very rich and flexible applications but there is one limitation when using pointer function. Windows API has limited support for function pointers because it has the ability to use but not the functional support to call back the function. But later versions have support for modules. Function pointers have inbuilt support (DLL`s) for call but not for call back.
Read More10 :: What is line option explicit?
Line explicit function makes the compiler to identify all the variables which are not specified by the dim statement. This command significantly reduces the problem of type errors. This is used extensively because VBA deals with information rich applications in which type errors are common.
Read More11 :: How to use data validation function in VBA?
Data validation is an important concept in VBA. Application procedure and a custom dialog box can be used to correct input errors. You can assign an application procedure to the frame of a dialog box. Error message or custom dialog box can be highlighted with the first field with errors.
Read More12 :: Explain What does Option Explicit refer to?
Option Explicit makes the declaration of Variables Mandatory
Read More14 :: Explain What do ByVal and ByRef mean and which is the default?
If you pass an argument by reference when calling a procedure, the procedure access to the actual variable in memory. As a result, the variable's value can be changed by the procedure.
If you pass an argument by value when calling a procedure, the variable's value can be changed with in the procedure only outside the actual value of the variable is retained.
Passing by reference is the default in VBA. If you do not explicitly specify to pass an argurment by value, VBA will pass it by reference.
Argument Passing ByVal
Describes passing arguments by value, which means the procedure cannot modify the variable itself.
Argument Passing ByRef
Describes passing arguments by reference, which means the procedure can modify the variable itself.
Read MoreIf you pass an argument by value when calling a procedure, the variable's value can be changed with in the procedure only outside the actual value of the variable is retained.
Passing by reference is the default in VBA. If you do not explicitly specify to pass an argurment by value, VBA will pass it by reference.
Argument Passing ByVal
Describes passing arguments by value, which means the procedure cannot modify the variable itself.
Argument Passing ByRef
Describes passing arguments by reference, which means the procedure can modify the variable itself.
15 :: Explain Which property of textbox cannot be changed at
runtime and what?s the maximum size of a textbox?
MultiLine Property
No limits
Read MoreNo limits
16 :: Explain Type Library and what is its purpose?
Type libraries are files that explicitly describe some or all of the contents of components. This includes information about the methods, properties, constants, and other members exposed by the component. Development tools such as Visual Basic make use of the information contained in the type library to help you, as a developer, access and use the component. In addition, type libraries provide a convenient way to include a simple level of descriptive documentation for component members.
Read More17 :: Explain Benefit of wrapping database calls into MTS transactions?
Benefit of wrapping database calls into MTS transa...
If database calls are made within the context of a transaction, aborting the transaction will undo and changes that occur within that transaction. This removes the possibility of stranded or partial data.
Read MoreIf database calls are made within the context of a transaction, aborting the transaction will undo and changes that occur within that transaction. This removes the possibility of stranded or partial data.
18 :: Explain Advantage of ActiveX Dll over Active Exe?
Advantages of ActiveX Dll
1) An in-process component shares its client?s address space, so property and method calls don?t have to be marshaled. This results in much faster performance.
Disadvantages of ActiveX Dll
1) If an unhandled error occurs it will cause the client process to stop operating.
Advantages of ActiveX Exe
1) The component can run as a standalone desktop application, like Microsoft Excel or Microsoft Word, in addition to providing objects.
2) The component can process requests on an independent thread of execution, notifying the client of task completion using events or asynchronous call-backs. This frees the client to respond to the user.
3)If an error occurs the client processes can continue to operate.
Disadvantages of ActiveX Exe
1) Generally slower than an ActiveX dll alternative.
Read More1) An in-process component shares its client?s address space, so property and method calls don?t have to be marshaled. This results in much faster performance.
Disadvantages of ActiveX Dll
1) If an unhandled error occurs it will cause the client process to stop operating.
Advantages of ActiveX Exe
1) The component can run as a standalone desktop application, like Microsoft Excel or Microsoft Word, in addition to providing objects.
2) The component can process requests on an independent thread of execution, notifying the client of task completion using events or asynchronous call-backs. This frees the client to respond to the user.
3)If an error occurs the client processes can continue to operate.
Disadvantages of ActiveX Exe
1) Generally slower than an ActiveX dll alternative.
19 :: Explain technical reasons which made Microsoft withdraw its support for VBA in Mac?
The reasons which made Microsoft drop its support to VBA are as follows, Microsoft visual basic relies heavily on machine code which was written for Power PC architecture. Also it would take another two years for developing VBA support for its architecture. It also states that Microsoft will incorporate VBA in the next script of office release for Mac.
Read More20 :: Explain about COM add-ins?
COM add-ins are software program`s which are integrated into an application and they add already built in features to an existing application. They have common architecture across multiple applications which help in deploying applications much faster across varied applications. Microsoft 2007 supports various COM add-INS
Read More21 :: Explain How to register a component?
To register component use
run command prompt type:
c: regsvr32 nameofcomp
For Activex DLL use:
RevSvr32 nameOfDll
For Activex Exe use:
NameOfExe /regServer
Read Morerun command prompt type:
c: regsvr32 nameofcomp
For Activex DLL use:
RevSvr32 nameOfDll
For Activex Exe use:
NameOfExe /regServer
22 :: Explain VB and Object Oriented Programming?
VB do supports oops.
Polymorphism - Yes , Encapsulation -Yes, Inheritance - NO
Read MorePolymorphism - Yes , Encapsulation -Yes, Inheritance - NO
23 :: Explain some general uses for Visual basic applications in general context?
Visual basic can be used within almost all Microsoft products such as Map point, Visio, Auto cad, Word perfect, ArcGIS, word, excel, etc. With VBA you can control many functions such as host application, menus, toolbars, user interface, import and export of files, data transfer and extraction from multiple interfaces.
Read More24 :: Explain What are the different compatibility types when we create a COM component?
No compatibility - creates new GUIDproject compatibility binary compatibility - maintains the references
Read More25 :: How to dial a phone number?
Shell command present in VBA can be used to start the dialer present in windows operating system. Phone number can be used to connect to your modem. With the use of shell and sendkeys you can dial to your user. Shell starts windows application and sendkeys inform the window to dial according to the keystrokes of the application. A macro can be used to start the cardfile program which activates the auto dialer feature.
Read More