1.
What's the difference between early binding and late binding ?
Interfaces
are the basic concept of COM. An interface is a group of methods . In case of
Late binding , the compiler has absolutely no idea of what the object and it
will execute the code.But early binding is exact opposite of late binding.In
early binding you create a reference to the ProgID by setting a reference in
the Project References menu. Early binding is faster compared to late binding.
Early binding and late binding refer to
the method used to bind an interface's properties and methods to an object
reference (variable). Early binding uses type library information at design
time to reference procedures, while late binding handles this at run time
2.
Threading
In COM objects live in apartments.
There are at present 2 kinds of apartments available:
- Single Threaded Apartments (STA).
- Multi Threaded Apartments (MTA).
There are at present 2 kinds of apartments available:
- Single Threaded Apartments (STA).
- Multi Threaded Apartments (MTA).
When a component has one thread of execution, code
for only one object can execute at any given time. The Automation feature of
the Component Object Model (COM) deals with this situation by serializing
requests. That is, the requests are queued and processed one at a time until
all have been completed
In Visual
Basic, apartment-model threading is used to provide thread safety. In
apartment-model threading, each thread is like an apartment — all objects
created on the thread live in this apartment, and are unaware of objects in
other apartments.Visual Basic’s implementation of apartment-model threading eliminates
conflicts in accessing global data from multiple threads by giving each
apartment its own copy of global data,
3. What is
the different between ActiveX EXE and ActiveX DLL ?
An ActiveX EXE runs out of process while an ActiveX
DLL runs in the same process space as
your app. Also, and ActiveX EXE can be run independent of your application if
desired. Other than that, both are used exactly the same from your VB
application.It should be noted that ActiveX dll is muchfaster than ActiveX Exe.
4. What does
the term "Inheritance" mean?
Inheritance, along with encapsulation and polymorphism, is one of the three pillars of object-oriented theory. Inheritance refers to the concept of deriving new objects from existing ones. This creates "is a type of" relationships between the object. Generally this works along the lines of specific object A is a type of general object B (ie. object "Poodle" is a type of "Dog" object). This classifying of objects into base types and sub types is also referred to as abstraction.
Inheritance can also take on different meanings. There is implementation inheritance
(sometimes called "true" inheritance), where a derived object
inherits the behavior (code) of its parent(s).
The derived object may use this behavior or in some cases may define its
own behavior for selected methods.
Interface inheritance, on the other hand, involves a derived object
sharing the same interface as its parent.
With interface inheritance, the derived class is responsible for
providing its own implementation for each inherited method.
5. What
does the term "Encapsulation" mean?
Encapsulation is one of the three pillars of object-oriented theory. It refers to hiding or protecting implementation details (such as data) within an object, only exposing that which is necessary, and controlling access (for example, providing functions to get and set data values, rather than providing direct access to variables).
Essentially, proper encapsulation makes an object a
"black box". The user of the
object provides the required input and receives an expected output, but has no
"under the hood" knowledge of how the object works.
6. What does the term
"polymorphism" mean?
In
essence, it means that objects can be more than one type of thing. We see this
every day in life: a two- seat convertible is a type of car which is a type of
vehicle. The same concept that applies to physical objects can also be applied
to software objects. Code that expects a parameter of type car should work
equally well with our two-seater or a stationwagon. This allows us to write
code that is either specific or abstract, depending on our needs.
7. Why should I use
property procedures instead of public variables in classes?
Property procedures represent control; always use them instead of public variables. Using public variables in a class means giving up the ability to validate changes to the class's data. Using property procedures is also the only way to get Read-Only or Write-Only properties.
8. How do I decide
which to create a normal bas module or a class module.
Class Modules .cls are vb's version of objects, simply an object is a group of functionality that sits together, for example Data Access. Anywhere where there is work done by the application should be in a class module.
Basic Modules .bas are for generic
functions, public constants and public enums Some functions.. formatSQL,
formatString, buildString, buildSQL : these type of functions are utility in
nature and should be put in a .bas module.
getRecordset, saveRecordset, getUser,
getAddress, processUserDetails : Are proccessing related functions and should
be placed into class modules along with thier family of functions and
properties, the class should hide the proccesses within. ie storeArticle(byval
title as string, byval body as string , byval author as string ) the data
access implicit in this function call is hidded within the class.
9. Is Visual Basic
an Object Oriented Language?
While
it offers encapsulation and polymorphism, its lack of implementation
inheritance makes the answer 'No' if you adhere to the strictest definition (VB
only offers interface inheritance). Visual Basic in its current form (version
6.0) is more of a component-based language. Its object technology is closely
bound to the Component Object Model (COM). The version known as VB.Net,
however, will meet
10. Three main
differences between flexgrid control and dbgrid control
11. Advantages of
disconnected recordsets
We've discussed
disconnected recordsets in Inside Microsoft Visual Basic several times.
Basically, these are recordsets that your code has purposefully disconnected
from the database, or that never had a connection to begin with. It may seem
strange to think of a recordset without an associated database, but many
developers build their own custom recordsets to use as storage objects, like
collections. In fact, some have argued that indexed, connectionless recordsets
are even faster than collections and arrays
12.Scope
of variables:
Scope
|
Private
|
Public
|
Procedure-level
|
Variables are private to the procedure in which they
appear.
|
Not applicable. You cannot declare public variables within
a procedure.
|
Module-level
|
Variables are private to the module in which they appear.
|
Variables are available to all modules.
|
Variables Used Within a Procedure
Procedure-level variables are
recognized only in the procedure in which they're declared. These re also known
as local variables. You declare them with the Dim or Static keywords. For
example:
Dim intTemp As Integer
–or–
Static intPermanent As Integer
Values
in local variables declared with Static exist the entire time your application
is running while variables declared with Dim exist only as long as the
procedure is executing.
Local variables are a good choice for
any kind of temporary calculation. For example, you can create a dozen
different procedures containing a variable called intTemp. As long as each
intTemp is declared as a local variable, each procedure recognizes only its own
version of intTemp. Any one procedure can alter the value in its local intTemp
without affecting intTemp variables in other procedures.
Variables Used Within a Module
By
default, a module-level variable is available to all the procedures in that
module, but not to code in other modules. You create module-level variables by
declaring them with the Private keyword in the Declarations section at the top
of the module. For example:
Private intTemp As Integer
At the module level, there is no
difference between Private and Dim, but Private is preferred because it readily
contrasts with Public and makes your code easier to understand.
Variables Used by All Modules
To make a module-level variable available to other modules,
use the Public keyword to declare the variable. The values in public variables
are available to all procedures in your application. Like all module-level
variables, public variables are declared in the Declarations section at the top
of the module. For example:
Public intTemp As Integer
Note You can't declare public variables within a procedure,
only within the Declarations section of a module.
13. Describe: In
of Process vs. Out of Process component. Which is faster?
Components provide reusable code in the
form of objects. An application that uses a component’s code, by creating
objects and calling their properties and methods, is referred to as a client.
An in-process component, or ActiveX DLL, runs
in another application’s process. The client may be the application itself, or
another in-process component that the application is using
Components can run either in-process or
out-of-process with respect to the clients that use their objects. An
out-of-process component, or ActiveX EXE, runs in its own address space. The
client is usually an application running in another process.
14.Difference
between
- Table-type Recordset
— representation in code of a base table that you can use to add, change,
or delete records from a single database table (Microsoft Jet workspaces
only).
- Dynaset-type Recordset
— the result of a query that can have updatable records. A dynaset-type
Recordset object is a dynamic set of records that you can use to add,
change, or delete records from an underlying database table or tables. A
dynaset-type Recordset object can contain fields from one or more tables
in a database. This type corresponds to an ODBC
keyset cursor.
- Snapshot-type
Recordset
— a static copy of a set of records that you can use to find data or
generate reports. A snapshot-type Recordset object can contain fields from
one or more tables in a database but can't be updated. This type
corresponds to an ODBC static
cursor.
- Forward-only-type
Recordset
— identical to a snapshot except that no cursor is provided. You can only
scroll forward through records. This improves performance in situations
where you only need to make a single pass through a result set. This type
corresponds to an ODBC forward-only
cursor.
- Dynamic-type
Recordset
— a query result set from one or more base tables in which you can add,
change, or delete records from a row-returning query. Further, records
other users add, delete, or edit in the base tables also appear in your
Recordset. This type corresponds to an ODBC dynamic cursor (ODBCDirect workspaces
only).
Linked Objects and Embeded objects:
Linked Objects :When you link an
object, you are inserting a placeholder (not the actual data itself) for the
linked object into your application. For example, when you link a range of
spreadsheet cells to a Visual Basic application, the data associated with the
cells is stored in another file; only a link to the data and an image of the
data are stored in the OLE container control. While working with your Visual
Basic application, a user can activate the linked object (by double-clicking
the object, for example), and the spreadsheet application will start
automatically. The user can then edit those spreadsheet cells using the
spreadsheet application. When editing a linked object, the editing is done in a
separate window outside the OLE container control.
Embedded Objects:To
create an embedded object, you can either use an OLE container control or add
an object's class to the Toolbox. With an embedded object, all the data
associated with the object is copied to and contained in the OLE container
control. When you save the contents of the control to a file, the file contains
the name of the application that produced the object, the object's data, and a
metafile image of the object. For this reason, embedded objects can greatly
increase file size.
Types of Locks:
adLockBatchOptimistic
Indicates
optimistic batch updates. Required for batch update mode.
Many
applications fetch a number of rows at once and then need to make coordinated
updates that include the entire set of rows to be inserted, updated, or
deleted. With batch cursors, only one round trip to the server is needed, thus
improving update performance and decreasing network traffic. Using a batch
cursor library, you can create a static cursor and then disconnect from the
data source. At this point you can make changes to the rows and subsequently
reconnect and post the changes to the data source in a batch.
adLockOptimistic
Indicates that
the provider uses optimistic locking—locking records only when you call the
Update method. This means that there is a chance that another user may change
the data between the time you edit the record and when you call Update, which creates
conflicts. Use this lock type in situations where the chances of a collision
are low or where collisions can be readily resolved.
adLockPessimistic
Indicates
pessimistic locking, record by record. The provider does what is necessary to
ensure successful editing of the records, usually by locking records at the
data source immediately before editing. Of course, this means that the records
are unavailable to other users once you begin to edit, until you release the
lock by calling Update. Use this type of lock in a system where you cannot
afford to have concurrent changes to data, such as in a reservation system.
adLockReadOnly
Indicates
read-only records. You cannot alter the data. A read-only lock is the
"fastest" type of lock because it does not require the server to
maintain a lock on the records.
adLockUnspecified
Does not specify
a type of lock.
Cursor
type
|
Constant
|
Static cursor. This is the one to use for generating
reports or finding data. Additions, changes, or deletions by other users are
not visible.
|
adOpenStatic
|
Forward-only cursor. This is the default. It is identical
to the Static except that you can only scroll forward. The fastest cursor
this side of the Pecos Mountains.
|
adOpenForwardOnly
|
Dynamic cursor. Additions and deletions by others are
visible. All movement is supported. But some providers don't support this
cursor type.
|
adOpenDynamic
|
Keyset-driven cursor. This is similar to a Dynamic cursor
except you can't see records others add. If another user deletes a record, it
is inaccessible from your recordset.
|
adOpenKeyset
|
We can also tell the recordset how to lock our data while
it's being manipulated via the cursor:
Lock
Type
|
Description
|
AdLockReadOnly
|
Default. Read-only: you cannot alter the data.
|
AdLockPessimistic
|
Pessimistic locking, record by record—the provider does
what is necessary to ensure successful editing of the records, usually by
locking records at the data source immediately upon editing.
|
AdLockOptimistic
|
Optimistic locking, record by record—the provider uses
optimistic locking, locking records only when you call the Update method.
|
AdLockBatchOptimistic
|
Optimistic batch updates—required for batch update mode as
opposed to immediate update mode.
|
15. What Is ADO?
ActiveX Data Objects is a programming model, which means
that it is not dependent upon any given back-end engine. ADO can access data
through any OLE DB provider. The following OLE DB providers ship with Microsoft
Data Access Components (MDAC) 2.0:
- Microsoft SQL
Server™
- Microsoft Jet
- Oracle
- OLE DB
Provider for ODBC (Kagera)
ODBC drivers are supported through the OLE DB Provider for
ODBC, often referred to as Kagera.
The ADO object model consists of seven objects:
- Connection:
Represents an open connection to an OLE DB data source.
- Error:
Contains details about data access errors, refreshed each time an error
occurs in a single operation involving ADO.
- Command:
Defines a specific command to execute against data.
- Parameter:
Optional collection off the Command object for any parameters to provide
to the command.
- Recordset:
Represents a set of records from a table, Command object, or SQL syntax.
Can be created without any underlying Connection object.
- Field:
Represents a single column of data in a recordset.
- Property: A
collection of values raised by the provider for ADO.
16.List out controls which does not
have events.
Imagelist
Control.
17.Maximum size of a text box is 32K.
Multiline property of textbox cant be changed at runtime.
18. What is.the difference between queryunload and unload in
form?
Difference
is between QueryUnload and Unload. Well, the main difference is that the
QueryUnload event is for asking the user "Do you want to save" and
"Are you sure?", and then tidying up user stuff, like saving changes
etc. The Unload event happens after the user has said "Yeah sure, go
ahead" and you have saved all the changes. Now you are tidying up the
system stuff - making sure all files are closed and all objects are set to
nothing. Also making sure that all other forms are also unloaded. You can
Cancel the unloading of the form at this point as well, although this is seldom
done and is not recommended unless doing so can save the user from potential
loss of data.
19. What is the difference between modal and moduless window?
20.What is the difference between change event in normal
combobox and dbcombobox?
ComboBox — changes the text in the text box portion of the
control. Occurs only if the Style property is set to 0 (Dropdown Combo) or 1
(Simple Combo) and the user changes the text or you change the Text property
setting through code.
21.Types of DBCombo box
1.DropDown 2.Simple and 3.DropdownList
22.Explain Get, Let, Set Properties.
Property Let Statement : Declares, in a Class block, the name,
arguments, and code that form the body of a Property procedure that assigns
(sets) the value of a property
Property Get Statement:
Declares,
in a Class block, the name, arguments, and code that form the body of a
Property procedure that gets (returns) the value of a property.
Property Set Statement:
Declares,
in a Class block, the name, arguments, and code that form the body of a
Property procedure that sets a reference to an object.
23.What is ActiveX Controls?
Microsoft® ActiveX® controls, formerly
known as OLE controls or OCX controls, are components (or objects) you can
insert into a Web page or other application to reuse packaged functionality
someone else programmed.
24.What is ActiveX Documents?
Using Visual Basic, you can create a complete application
with the semantics of a traditional document. In other words, you have the
functionality of the application, but the flexibility of a document's behavior
— when a user opens an ActiveX document, she will not only have the full
functionality of an application, but the ability to persist and distribute
"copies" of the data intrinsic to the application. Thus, the
"document" is truly active
25.Types of Views in
Listview Control.
LvwIcon,LvwSmallIcon,Lvwlist,LvwReport
26. What are the Internet tools available in VB6.0?
WebBrowser Control, Microsoft Internet Transfer Control,MAPI
Session, MAPI Messages.
27. What do you mean by ADO?
28. What is the difference Between ADO and other data access
objects?
29. WhatisOLEDB?
30. What are the important components of OLEDB?
31. Through which protocol OLEDB components are interfaced?
32. It possible to call OLEDB's Features directly in VB
without using any control?
33.Difference
between Byval and Byref.
Selecting a ByVal mean you are only working on a copy or
replica of the data, and not the actual data.
The ByRef use, would imply that a change performed by the
statement of the value you pass, has an affect on the actual data, while the
ByVal use would only alter the copy the statement has to work on
34.What
is a callback Function?
A callback function is code within a managed application
that helps an unmanaged DLL function complete a task. Calls to a callback
function pass indirectly from a managed application, through a DLL function,
and back to the managed implementation
Callback Function Basics
To call most DLL functions from managed
code, you create a managed definition of the function and then call it. The
process is straightforward.
Using a DLL function that requires a
callback function has some additional steps. First, you must determine whether
the function requires a callback by looking at the documentation for the
function. Next, you have to create the callback function in your managed
application. Finally, you call the DLL function, passing a pointer to the
callback function as an argument. The following illustration summarizes these
steps.
|
|
|
|
Unmanaged Managed
35.What
is a class?
Classes are symbolic representations of
objects; they describe the properties, fields, methods, and events. The terms
"class" and "object" are sometimes used interchangeably,
but in fact, classes describe the structure of objects, while objects are
usable instances of classes. Each instance is an exact yet distinct copy of its
class. Because an object is an "instance" of a class, the act of
creating an object is called instantiation
How would you
create a new instance of a class?
To create an instance of a class, use the New keyword.
Unlike value types, such as Integer and Double, objects are reference types,
and you must explicitly create them before you can use them.
Dim Button1 As System.Windows.Forms.Button
Instancing
Property:
1 (Default) Private. Other applications aren’t allowed
access to type library information about the class, and cannot create instances
of it. Private objects are only for use within your component.
The Instancing property default varies depending on the
project type. Private is the default only for class modules in Standard Exe
projects.
When you insert a new class module into an ActiveX Exe
project or an ActiveX DLL project, the default value of the Instancing property
is MultiUse. When you insert a new class module into an ActiveX Control
project, the default value of the Instancing property is PublicNotCreatable
2 PublicNotCreatable. Other
applications can use objects of this class only if your component creates the
objects first. Other applications cannot use the CreateObject function or the
New operator to create objects from the class.
3 SingleUse. Allows other applications
to create objects from the class, but every object of this class that a client
creates starts a new instance of your component. Not allowed in ActiveX DLL
projects.
4 GlobalSingleUse. Similar to
SingleUse, except that properties and methods of the class can be invoked as if
they were simply global functions. Not allowed in ActiveX DLL projects.
5 MultiUse. Allows other applications
to create objects from the class. One instance of your component can provide
any number of objects created in this fashion.
6 GlobalMultiUse. Similar to MultiUse, with one addition:
properties and methods of the class can be invoked as if they were simply
global functions. It’s not necessary to explicitly create an instance of the
class first, because one will automatically be created.
36.Threads:
Operating systems use processes to separate the different
applications that they are executing. Threads are the basic unit to which an
operating system allocates processor time, and more than one thread can be
executing code inside that process. Each thread maintains exception handlers, a
scheduling priority, and a set of structures the system uses to save the thread
context until it is scheduled. The thread context includes all the information
the thread needs to seamlessly resume execution, including the thread's set of
CPU registers and stack, in the address space of the thread's host process
The .NET Framework further subdivides
an operating system process into lightweight managed subprocesses, called
application domains, represented by System.AppDomain.
One or more managed threads (represented by System.Threading.Thread)
can run in one or any number of application domains within the same unmanaged
process. Although each application domain is started with a single thread, code
in that application domain can create additional application domains and
additional threads. The result is that a managed thread can move freely between
application domains inside the same unmanaged process; you might have only one
thread moving among several application domains.
Advantages of
Multiple Threads:
Communicate over a network, to a Web server, and to a
database. Perform operations that take a large amount of time. Distinguish
tasks of varying priority. For example, a high-priority thread manages
time-critical tasks, and a low-priority thread performs other tasks. Allow the
user interface to remain responsive, while allocating time to background tasks.
Disadvantages of
Multiple Threads:
The system consumes memory for the context information
required by processes, AppDomain objects, and threads. Therefore, the number of
processes, AppDomain objects, and threads that can be created is limited by
available memory.
Keeping track of a large number of threads consumes
significant processor time. If there are too many threads, most of them will
not make significant progress. If most of the current threads are in one
process, threads in other processes are scheduled less frequently.
Controlling code execution with many threads is complex,
and can be a source of many bugs. Destroying threads requires knowing what
could happen and handling those issues.
No comments:
Post a Comment