Thursday, July 17, 2008

Visual Basic Questions


1) What is the sequence
Initialise, Load, Resize, Paint
2) You want to represent hierarchically an organisation's structure in a WWW
site along with Icons. Which control will you make use of ?
Treeview
3) You have created an application. In the Help menu, you have an option to
navigate to a WWW site. What you should make use of ?
Winsock
4) dim a as class1
dim b as new class1
b.prop = true
set a = new class1
How many instances of class1 is created ?
2
5) Which of the following is required for early binding ?
type library
New Keyword
6) Which property of Err object gives you an idea of where the error has
occured ?
Source
7) How do you test an in-process ActiveX DLL ?
8) How do you test an out-of-process ActiveX EXE ?
9) Private sub mysub() as integer
static count as integer
if count >= 4 then
exit sub
else
mysub
end if
end sub
What will be the output ?
Out of stack error
10) You have debug statement in your project. You don't want them to be
compiled. What can you do Conditional compilation
Use Edit and Replace
11) You are making use of pass by reference. How will you optimize numeric
calculation.
Assume no aliasing
Remove FDIV checks
Remove floating point error checks
12) You are making use of Pentium Pro computer. How can you optimize ?
13) You have created a class. You want other members of your project to
access it. You want them to access it like an app object. How do you set the
instancing ?
Globalmultiuse
multiuse
Publicnotcreatable
Private
14) What are the valid properties of control collection ?
15) What should you do if you want to uninstall your software (when you are
using setup wizard ) ?

Some Questions
**************

1.How do you create an instance of the form

2.What are the uses of the forms collection

3.What is the sequence in which the events in the form will trigger

4.What can you do with your Popup menus

•Dynamically create the menus •Deleting the menus created if not needed

5. What property cannot be send for the menus in the run time shortcut keys cannot be set in run time

6 .How do you dynamically create a menu
load mnufile(1)
7. Drophighlight property of the treeview when it is used

It is used along with the hittest property to highlight the control when ole
controls are dropped on it
8. If you want to create a hierarchical view for the world wide web what
control will you use
Treeview
9. What property will you use in the toolbar control to code for the events
button.index
10. What property should you use for showing text in the status bar
statusbar1.panales(1).text="processing...."
11.what are the disadvantages of using the implements keyword
12. If you want to merge the menu option of the object along with the menu
option of the form in which the object is placed what property should you use
13.When can you add watch expressions in the watch planes(very confusing
question) some of the options where any time any time when you do not have
a modal window only during design mode
14.What are the advantages of using the watch window(Check box)
15.What will be there in the local window
•all the variables in the application •all the variables in the modules
•all the variables in the procedure •all the variables in the procedure scope

Some Questions
**************

1. What is the DBGrids default RecordSoruce type
2. I have set one option buttons HelpcontextID to 0, and the user press F1
what will happen?
If HelpContextID is set to 0, then Visual Basic looks in the HelpContextID
of the object's container, and then that object's container, and so on.
If a nonzero current context number can't be found, the F1 key is ignored.
3. What object do i use for the ShowHelp metod
Before you use the ShowHelp method, you must set the HelpFile and HelpCommand
properties of the CommonDialog control to one of their appropriate constants
or values. Otherwise, Winhlp32.exe doesn't display the Help file.
4. What object is used if i want to change label1 on usercontrol1background
color?
5. What limitations has Implenents keyword (Choose 2)?
The Implements statement can't appear in a standard module. A type library
containing abstract interfaces provides a reference point for both implementing
and using interfaces. In order to implement an interface, you must use the
References dialog box to set a reference to the type library. This is because
the type library contains the information required to specify the arguments
and return types of the interface's members.
In similar fashion, any application that uses objects which have implemented
an abstract interface must also have a reference to the type library that
describes the interface. Information about implemented interfaces cannot be
included in the type libraries of components, because there is no way to
resolve naming conflicts.
6. ActiveX and errors. How to use Err.Rasierror
a)Raise method of the Err object to raise errors in a client application that
calls methods provided by your component.
7. ActiveX component distrubution. How to this the fastes way?
a)The Setup Wizard will create a .cab file, known as the primary .cab file,
which contains the following:
The project components, such as the ActiveX control, ActiveX DLL, or
ActiveX EXE.
The .inf file, which contains links to other .cab files that contain Visual
Basic support files and controls, as well as other information, such as
whether the control is safe for scripting and safe for initialization and
registry information as defined by the user. This file replaces the Setup.lst
file that the Setup Wizard creates in the standard setup. Reserved space for
digital signatures.
All files that are not in other (secondary) .cab files.
Secondary .Cab Files
For ActiveX control projects, ActiveX EXEs, and ActiveX DLLs, all run-time
components such as Msvbvm50.dll, individual controls, Data Access Objects
(DAO), and Remote Data Objects (RDO) are packaged into separate .cab files,
digitally signed by Microsoft, and placed on the Microsoft Website. You can
choose to link your files to the .cab files on the Microsoft Web site, or you
can download local copies of them.
The benefit of using secondary .cab files from an Web site are:
You do not need to distribute all of the .cab files required by your
application. The only file you need to distribute is the primary .cab file.
The .inf file within the primary .cab file points to the Microsoft Web site
and downloads the necessary .cab files based on the needs of the end user.
They provide an efficient means of delivering updates to your product.

If you cannot or do not want your application setup to require a connection
to the Internet, you may place the secondary .cab files on a server within
your intranet. An intranet allows for faster downloading while allowing users
to remain on secured network.
8. Add watch. What is the meaning of the Context group?
a)Sets the scope of variables watched in the expression. Use if you have
variables of the same name with different scope. You can also restrict the
scope of variables in watch expressions to a specific procedure or to a
specific form or module, or you can have it apply to the entire application
by selecting All Procedures and All Modules. Visual Basic can evaluate a
variable in a narrow context more quickly.
9. What does locales show in different contexts?
10. What will be shown when this code is executed?
Private Sub Command1_Click()
Command2.Value = True
End Sub
Private Sub Command2_Click()
Command1.Value = True
End Sub
Out of Stack Space
11. In what order does a form go trough and in what order?
Initilize, Load, Rezise, Paint?
12. Load controls with Load Statement and index
Load object(index%)
Unload object(index%)
13. What will happen if user presses command2?
Sub Mysub()
Static intNum As Integer
If intNum <= 4 Then
Exit Sub
Else
intNum = intNum + 1
Mysub
End If
End Sub
Private Sub Command2_Click()
Mysub
End Sub
The code will run OK
14. How to declare av DLL with a C Char datatype?
a)ByVal variable As Byte
15. How to use the Form collection?
a)Dim a As Form
For Each a In Forms
MsgBox a.Caption
Next
16. Learn TreeView and Drag and drop, OLE dragover event

Some Questions
**************

1)What code will have the most to gain on to be compiled to Native Code?
•Code that uses windows API •Codet that has much String functions
•Code that manipulates objects •Code that have complex Finincal calculations
(*)
2)What elements exists in Conditional Compiling
a)Litera Expressions
3)What event can handle when a user presess F2
a)Key Down and Key Up
4.How to debugg an .OCX (Its an in-process DLL) with an project group (3 Q)
Why are an user control dimmed on the toolbar?
a)The user control designer has to be closed
5)When can you add watch variables?
a)In Break and design mode
6)Where do you define conditional compiling variables?
a)Project options and VB.EXE
Registry Settings i saved in HKEY_USERS
7)What project types can have ActiveX documents?
All that can be an container
8)When to use GetObject and Create Objects?
9)Where and why to use Friend metods and properties


My set of exam questions
************************

1. which property sets the value to indicate the display of a lengthy
operation?
Value
2)Dragover event of form1 to change bg color of label 1 to red/source.color
=vbred
3)Trap a function key
a)keydown
4)To allow numeric digit only ina txt box which is unbound?
a)keypress
5)Prpperty to access buttons of toolbar?
a)Key and Index
6) Inserting text to statusbar SBI second panel ?
sb1.panels(2).text = "....printing"
7)default recordset
dynaset type recordset
8)lokedits = false
optimistic locking
9)pass an empty valu
a)byval 0& byref vbnullstring
10)which 2 projects contain ActiveX documents
a)Active X.exe and activex.dll
11)activex.dll to multithread
a)activex.exe (convert)
12)when helpcontextid =0 for an object conatined in a frame where does visual basic look for help?
In the controls container
13)what code will gain from being compiled as native code?
a)finacial calculations
14)what cannot be done when an internet control is packaged?
a)write from registry,reading from registry.
15)benefits of form collection
a)Standardised mechanism for for tracking multiple instances of a form
unloading all forms is faster.

Some Questions
**************

1.If you want to install your Visual Basic application in other computer,how
do you find out about the components that are registered in that computer?
a)REGSRV32.EXE
2.How can you build ActiveX components for Internet distribution?
a)Use the Application Setup Wizard and pick the appropriate options.
3.What type of files does the Setup Wizard generates for Internet
download setup?
a)*.CAB files.
4.Know all elements shown in the Add Watch Window (Debugging)
5.Know all elements shown in the Locals Window (Debugging)
6.Know allpossible type of files that can you register by using REGSRV32.EXE.
(i.e.: .DLL, .OCX, etc.)
7.How can you test the unload behavior of an in-process (ActiveX) DLL
component?
a)You can add a standard EXE project to the ActiveX DLL¦s project group, and
test the in-process component within a single instance of Visual Basic.
8.How can you debug an (ActiveX) out-of-process component?
a)To test an ActiveX EXE, you must run the component within one instance of
Visual Basic,and run the test application in a second instance of VisualBasic.
9.Know all the options available within the "Compile" tab in the Project Properties
when making a new project. (i.e.: Compile to Native Code -> Favor Pentium Pro
(tm), Advanced Optimizations -> Remove Integer Overflow Checks, etc.)
10.Variable a is in Procedure A. In the Locals Window we observe its current
value. Then you step into to Procedure B and variable a shows a message "out
of context". What does it mean? Variable a was local to Procedure A (neither
public nor static).
11.One question on conditional compilation to choose the right construct
(learn the syntax for #ifdef #elseif #endif)
12.There is a www server application that uses ActiveX controls you developed
.When the application page is browsed with IE it does not show the ActiveX
control. What may be happening?
a)Options in the Application Setup Wizard were not used correctly.
13.Which (2) of the following make a safe ActiveX scripting control for
www applications
[ ] Prompt for a password
[ ] Save to a File
[X] Get information from registry
[X] Save information to registry.
14.What options (switches) should you select in order to optimize performance
for numeric processing while the compiler relies on arguments passed by
reference.
[ ] Assume No Aliasing
[ ] Optimizing for Small Code
[X] Disable Visual Basic Floating Point Error Checking
[X] Remove Safe Pentium FDIV Checks
15.You have Form1 where you drag and place a label named Label1. Pick the
correct line of code that changes the background color of Label1.
16.There is Form1 that has Object1. How can you combine the menu controls of
Object1 in Form1? Using a pop-up menu at run-time. Another option could be to
set the NegociateMenu property of Form1 to true.
17.You set a form with AutoRedraw = False. You have a command button, an
image control, a draw made by the PSET instruction, and a text that uses
the PRINT method. If the form is minimized and then restored, there are two
elements that are going to be di
The Command Button and the Image Control 18.If you want to display a
hierarchical structure of a Web Site, which of the following controls you
should use?
[ ] outline
[ ] listbox
[ ] listview
[X] treeView
19.What can you do with a dynamic menu?:
[ ] You can add function keys to it
[X] You can add pop-up menus to it
[X] You can deleted it after creating it
[ ] You can create it from the MenuEditor
20.Know the DropHighLight property of TreeView.
The DropHighLight property is used to do drag and drop operations in a
TreeView.
21.Characteristics of the DragOver Event.
Used for drag and drop operations with forms, and other objects as pictures.
22.If you want to offer an option in a help menu for users to access your
Web Site, what ActiveX Document should you use?:
[ ] Automation
[ ] WinSock
[X] Hyperlink
[ ] ActiveX component
23.Know the function and syntax of Param Array
24.Know all about how to implement HelpFiles in an application
25.If we have an ActiveX Component that connects to a database, how can it
be notified if the component connection
fails?
26.Know all about using class modules
27.Know how to declare DLL functions.
28.You have an ActiveX document that uses the AsyncRead method to obtain data
from an intranet location. What type of data does it cannot return directly?
[ ] Files
[ ] Byte arrays
[ ] Pictures
[X] Hyperlinks
29.What is the purpose of the Implements keyword?
a)The Implements keyword is used to create a secondary interface.
For instance, if your application has a reference to a type library that
describes the IGrowth interface, you could create a secondary interface in
a class module using "Implements IGrowth".
30.Why would you want to set theLockEdits property to False?
If LockEdits is set to False (for optimistic locking), then the 2K page
containing the record will remain locked, and then updated upon executing the
Update method only.
31.We obtained many DLL functions from different vendors. Two functions happen
to have the same name but different purposes. What can we do?
[X] Using an alias
[X] Declaring each Private in separate modules
[ ] Registering one with another name
[ ] Modifying the DLL function.
32.Know the differences between early binding vs late binding
Late binding occurs when the compiler does not know about an object until run
time.
a)Early binding occurs when Visual Basic knows at compile time exactly which
interface will be used with an object variable.
33.One question related to sink events for a class named CLASS1 and some
possible answers like:
( ) Dim MyVar AS OBJECT
( ) Dim MyVar AS Variant
( ) Dim MyVar AS New Class1
( ) Dim WithEvents MyVar as Class1
34.Know all about Forms Collection 35.Which line of code will create a new
instance of an object new Form1 in Project1.
[ ] Dim Frmx as Form1
[ ] Dim Frmx as New Form1
[ ] Set Frmx = Form1
[X] Set Frmx = GetObject("Project1.Form1")
36.How can you create a read-only property for a class?
[ ] Define a Property Get procedure and define a Property Let procedure with
no arguments.
[ ] Define a Property Get procedure and a Property Let procedure.
[X] Define a Property Get procedure without a Property Set or Property Let
procedure.
[ ] Define a Property Set or Property Let procedure without a Property Get
procedure.
37.Advantages of Using ActiveX Documents (Choose 2).
The ActiveX Documents offer many advantages and increased functionality to
both the user and the application developer. The most important advantage
for developers in using ActiveX documents is the ability to apply existing
programming skills. Developers
38.What is the purpose of the ID parametr in an HTML tag?
[ ] Specifies a URL that points to a file containing an implementation of an
object.
[ ] Specifies the object's unique class identifier stored in the system
registry.
[ ] Specifies a URL that points to the name of the object.
[X]Specifies the object name.
39.How can you create a read-only property private and a write-only property
Public. Which of the following are true?
[X] Private Property Get Name() As String
Name = txtname.text
End Property
Public Property Let Name(ByVal NewName as String)
TxtName.text = NewName
PropertyChanged "Name"
EndProperty
[ ] Public Property Set Name() As String
Name = txtname.text
End Property
Private Property Let Name(ByVal NewName as String)
TxtName.text = NewName
PropertyChanged "Name"
EndProperty
[ ] Public Property Let Name() As String
Nsme = txtname.text
End Property
Public Property Set Name(ByVal NewName as String)
TxtName.text = NewName
PropertyChanged "Name"
EndProperty
40.How do you create a license package file containing the licensing
information for all controls on a Web page?
[ ] With the Visual Basic License Manager.
[ ] With the CODEBASE parameter of an HTML page'stag.
[ ] With the Visual Basic Application Wizard.
[X] With a utility form the LPK_TOOL directory on the Visual Basic CDROM.
41.What elements of ActiveX Components on a Web page contribute to security?
When you use ActiveX controls on a Web page, you can implement the
following security measures: Set the appropiate level of security in Internet
Explorer, Provide users with information about the author of the control,
Through digital code signing, Create an Internet download by marking your
Controls as safe for scripting and initialization.
42.Which code segment would best trap a "division by zero" error handling?
For example: (See Error Handling)
Public Sub ProcDivZero()
On Error GoTo ErrTrapper
X = 100 / 0
Y = X / 0
Exit Sub
End Sub
ErrTrapper
If Err.Number = 11 Then Debug.Print "Division by Zero Found"
EndProc
43.Which is the difference between debugging an ActiveX control project and
an in-process component?
a)The componet code can run while the client is in Design mode. (See
Mastering VB5: ActiveX Control).
44.Which project template would you select to build an in-process code
(ActiveX Document DLL)?
a)Add object dialog.
questions
---------

1.If you want to install your Visual Basic application in other computer, how
do you find out about the components that are registered in that computer?
a)REGSRV32.EXE
2.How can you build ActiveX components for Internet distribution?
a)Use the Application Setup Wizard and pick the appropriate options.
3.What type of files does the Setup Wizard generates for Internet download
setup?
*.CAB files.
4.Know all elements shown in the Add Watch Window (Debugging)
5.Know all elements shown in the Locals Window (Debugging)
6.Know all possible type of files that can you register by using REGSRV32.EXE.
(i.e.: .DLL, .OCX, etc.)
7.How can you test the unload behavior of an in-process (ActiveX) DLL
component?
a) You can add a standard EXE project to the ActiveX DLL¦s project group,
and test the in-process component within a single instance of Visual Basic.
8.How can you debug an (ActiveX) out-of-process component? To test an
ActiveX EXE, you must run the compon iable a shows a message "out of context"
What does it mean?
a)Variable a was local to Procedure A (neither public nor static).
9.One question on conditional compilation to choose the right construct
(learn the syntax for #ifdef #elseif #endif)
10.There is a www server application that uses ActiveX controls you developed.
When the application page is browsed with IE it does not show the ActiveX
control. What may be happening?
a)Options in the Application Setup Wizard were not used correctly.
11.Which (2) of the following make a safe ActiveX scripting control for www
applications
[ ] Prompt for a password
[ ] Save to a File
[X] Get information from registry
[X] Save information to registry.
12.What options (switches) should you select in order to optimize performance
for numeric processing while the compiler relies on arguments passed by
reference.
[ ] Assume No Aliasing
[ ] Optimizing for Small Code
[X] Disable Visual Basic Floating Point Error Checking
[X] Remove Safe Pentium FDIV Checks
13.You have Form1 where you drag and place a label named Label1. Pick the
correct line of code that changes the background color of Label1.
14.There is Form1 that has Object1. How can you combine the menu controls of
Object1 in Form1?
a)Using a pop-up menu at run-time.Another option could be to set the Negociate
Menu property of Form1 to true.
15.You set a form with AutoRedraw = False. You have a command button, an
image control, a draw made by the PSET instruction, and a text that uses the
PRINT method. If the form is minimized and then restored, there are two
elements that are going to be di
a)The Command Button and the Image Control
16.If you want to display a hierarchical structure of a Web Site, which of
the following controls you should use?
[ ] outline
[ ] listbox
[ ] listview
[X] treeView
17.What can you do with a dynamic menu?:
[ ] You can add function keys to it
[X] You can add pop-up menus to it
[X] You can deleted it after creating it
[ ] You can create it from the MenuEditor
18.Know the DropHighLight property of TreeView.
The DropHighLight property is used to do drag and drop operations in a
TreeView.
19.Characteristics of the DragOver Event.
a)Used for drag and drop operations with forms, and other objects as pictures.
20.If you want to offer an option in a help menu for users to access your Web
Site, what ActiveX Document should you use?:
[ ] Automation
[ ] WinSock
[X] Hyperlink
[ ] ActiveX component
21.Know the function and syntax of Param Array
22.Know all about how to implement HelpFiles in an application
23.If we have an ActiveX Component that connects to a database, how can it be
notified if the component connection fails?
24.Know all about using class modules
25.Know how to declare DLL functions.
26.You have an ActiveX document that uses the AsyncRead method to obtain data
from an intranet location. What type of data does it cannot return directly?
[ ] Files
[ ] Byte arrays
[ ] Pictures
[X] Hyperlinks
27.What is the purpose of the Implements keyword?
The Implements keyword is used to create a secondary interface. For instance,
if your application has a reference to a type library that describes the
IGrowth interface, you could create a secondary interface in a class module
using "Implements IGrowth".
28.Why would you want to set the LockEdits property to False?
If LockEdits is set to False (for optimistic locking), then the 2K page
containing the record will remain locked, and then updated upon executing the
Update method only.
29.We obtained many DLL functions from different vendors. Two functions
happen to have the same name but different purposes. What can we do?
[X] Using an alias
[X] Declaring each Private in separate modules
[ ] Registering one with another name
[ ] Modifying the DLL function.
30.Know the differences between early binding vs late binding
Late binding occurs when the compiler does not know about an object until run
time.Early binding occurs when Visual Basic knows at compile time exactly
which interface will be used with an object variable.
31.One question related to sink events for a class named CLASS1 and some
possible answers like:
( ) Dim MyVar AS OBJECT
( ) Dim MyVar AS Variant
( ) Dim MyVar AS New Class1
(*) Dim WithEvents MyVar as Class1
32.Know all about Forms Collection 33.Which line of code will create a new
instance of an object new Form1 in Project1.
[ ] Dim Frmx as Form1
[ ] Dim Frmx as New Form1
[ ] Set Frmx = Form1
[X] Set Frmx = GetObject("Project1.Form1")
34.How can you create a read-only property for a class?
[ ] Define a Property Get procedure and define a Property Let procedure with
no arguments.
[ ] Define a Property Get procedure and a Property Let procedure.
[X] Define a Property Get procedure without a Property Set or Property Let
procedure.
[ ] Define a Property Set or Property Let procedure without a Property Get
procedure.
35.Advantages of Using ActiveX Documents (Choose 2).
a)The ActiveX Documents offer many advantages and increased functionality to
both the user and the application developer. The most important advantage for
developers in using ActiveX documents is the ability to apply existing
programming skills. Developers
36.What is the purpose of the ID parametr in an HTML tag?
[ ] Specifies a URL that points to a file containing an implementation of an
object.
[ ] Specifies the object's unique class identifier stored in the system
registry.
[ ] Specifies a URL that points to the name of the object.
[X]Specifies the object name.
37.How can you create a read-only property private and a write-only property
Public. Which of the following are true?
[X] Private Property Get Name() As String
Name = txtname.text
End Property
Public Property Let Name(ByVal NewName as String)
TxtName.text = NewName
PropertyChanged "Name"
EndProperty
[ ] Public Property Set Name() As String
Name = txtname.text
End Property
Private Property Let Name(ByVal NewName as String)
TxtName.text = NewName
PropertyChanged "Name"
EndProperty
[ ] Public Property Let Name() As String
Nsme = txtname.text
End Property
Public Property Set Name(ByVal NewName as String)
TxtName.text = NewName
PropertyChanged "Name"
EndProperty
38.How do you create a license package file containing the licensing
information for all controls on a Web page?
[ ] With the Visual Basic License Manager.
[ ] With the CODEBASE parameter of an HTML page'stag.
[ ] With the Visual Basic Application Wizard.
[X] With a utility form the LPK_TOOL directory on the Visual Basic CDROM.
39.What elements of ActiveX Components on a Web page contribute to security?
When you use ActiveX controls on a Web page, you can implement the
following security measures:
Set the appropiate level of security in InternetExplorer, Provide users with
information about the author of the control,Through digital code signing,
create an Internet download by marking your Controls as safe for scripting
and initialization.
40.Which code segment would best trap a "division by zero" error handling?
For example: (See Error Handling)
Public Sub ProcDivZero()
On Error GoTo ErrTrapper
X = 100 / 0
Y = X / 0
Exit Sub
End Sub
ErrTrapper
If Err.Number = 11 Then Debug.Print "Division by Zero Found"
EndProc
41.Which is the difference between debugging an ActiveX control project and
an in-process component?
The componet code can run while the client is in Design mode. (See Mastering
VB5: ActiveX Control).
42.Which project template would you select to build an in-process code
(ActiveX Document DLL)?
a)Add object dialog.

Your Title