Thursday, July 17, 2008

visual basic questions 6

1) When can you add a Watch? (2)
Design time
While code execution is suspended
Run time
Run time except during modal dialogue boxes
2) What are the advantages of using the context property when using the Watch
window?
3) An project MyProj has an object MyObj with a friend method called MySub.
How can MyObj be declared in order to allow access my sub?
as MyObj anywhere within MyProj
as MyObj from any project
as Object from anywhere within MyProj
as MyObj from any project with a reference to MyProj added
4) What are the advantages of using secondry .cab files?
5) Under what circumstances would compiling to native code instead of P code
give best results?
if the application does a lot of string manipulation
if the application is a financial application
if a lot of Win32 API calls are made
6) private sub command1_click
on error goto cmdErr:
Sub1
Msgbox "YY"
exit sub
cmdErr:
Msgbox "ZZ"
end sub
private sub Sub1
dim x as integer
on error goto subErr:
x = 10 / 0
exit sub
subErr:
Msgbox "XX"
end sub
What messages are displayed when user clicks on command1?
yy
xx
xx , yy
xx, yy, zz
7) What two types support ActiveDocuments?
standard.exe
ActiveX.dll
ActiveX.exe
AxtiveX control
8) How would you make a public read, private read/write property?
9) A status bar (sb1) has two panels, the second one with key name
'Panel2'. Which is correct?
sb1.Panel.Items('Panel2').Text = 'asdf'
sb1.Panels(2).Text = 'asf'
sb1.Panels.Index('Panel2').Text = 'adf'
10) If you want to drag a picture from a form, what property must be set?
11) Which control can be placed on an MDI Form
Picture
Image
Treeview
Button
12) What property must be used with TreeView's DropHighlight?
13) Which method provides the simplest way to FTP?
Internet control
webcontrol
winsock
Hyperlink
14) Which is the correct syntax:
AddressOf ("MySub")
AddressOf (MySub)
AddressOf MySub
AddressOf "MySub"
16) A UserControl contains a listbox control with the sorted property
exposed. Why do you get an error if the sorted property is set at   design
time?  (because listbox control does not have a propertybag and cannot be run
in design mode like the UserControl)
17) private sub main
Form1.Caption = "Hello"
end sub
what events on form1 get called?
Load,
Load, Activate
Initialise, Load
Initialise, Load, Activate
1. You have a command button Command1 with code for some event on Form1.
You select the command button, cut it from Form1 and paste it onto form2.
Now where is the code for the event of Command1?
[X] In the general section of Form1
[ ] In the general section of Form2
[ ] .....
[ ] .....
2. Which (2) of the following make an ActiveX scripting control unsafe
for www applications
[X] One that creates a password
[X] Save to a File
[ ] Get information from registry
[ ] Save information to registry.
3. You have developed an application which will run exclusively on a
Pentium Pro. What options will you select yo optimize numeric operations?
[ ] Assume No Aliasing
[ ] Optimizing for Small Code
[X] Disable Visual Basic Floating Point Error Checking
[X] Remove Safe Pentium FDIV Checks
4. You drag Label1 on Form1 and drop it on some control on Form1. What line
of code will change the background color of Label1 to red?
[ ] label1.backcolor = vbred
[ ] label1.color = vbRed
[X] Source.Backcolor = vbRed
[ ] .....
5. There is Form1 that has Object1. How can you combine the menu controls
of Object1 in Form1?
[ ] NegotiatePosition = True
[X] NegotiateMenus = True
[ ] ......
[ ] ......
6. 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 dis
The Command Button and the Image Control
7. 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
8. If you want to offer an option in a help menu for users to access your
Web Site, what Component should you use?
[ ] Automation
[ ] WinSock
[X] Hyperlink
[ ] ActiveX component
9. If we have an ActiveX Component that connects to a database, how can the
client be notified if the component connection fails?
by raising events or Callbacks
oR
use Err.Raise Method in the Activex Component
10. You have an ActiveX document that uses the AsyncRead method to obtain
data from an intranet location. What type of data can it not return directly?
[ ] Files
[ ] Byte arrays
[ ] Pictures
[X] Hyperlinks
11. 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.
12. How do you declare an object variable so that it is able to sink events?
[ ] Dim MyVar AS OBJECT
[ ] Dim MyVar AS Variant
[ ] Dim MyVar AS New Class1
[X] Dim WithEvents MyVar as Class1
13. 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")
14. How do you pass a null function pointer to a DLL from VB?
Ans. Use the AddressOf Operator.
15. What object do you use for the ShowHelp method?
Use the CommonDialog Control
16. You want to minimize download time for an activeX document with several
components. How to package within a .cab file?
Ans.
17. IIS cannot instantiate an object provided by the DLL (ActiveX). What
should you do to the DLL?
Ans. Register the Activex DLL on the user's computer using "regsvr32.exe
18. You design a class for use all programmers in the company in a
project. You want users to be able to access the methods of the class
without creating a new instance of it. How will you do this?
[ ] Set the instancing property of the control to MultiUse
[X] Set the instancing property of the control to GlobalMultiUse
[ ] .............
[ ] .............
19. Which two required for Early Binding?
[X] Type library
[ ] Dual Interface
[X] New Keyword ?
[ ] CreateObject Function
20. What should you do to debug an out of process component
[X] Start a second instance of the development environment
[ ] Compile the component by using symbolic debug information
[ ] Create an errorhandler for the out of process component
[ ] Create a project group
21. What is the sequence in which the events in a form will trigger?
ILRAP Ó Initialize, Load, Resize , Activate, Paint
Note : When a Form is unloaded the sequence is ---> QueryUnload, Unload,
Terminate
22. How do you dynamically create a Commnad button . Already a Command
Button with index 0 exists.
Load Command1(1)
23. What will happen when this code is executed?
Private Sub Command1_Click()
command2.Value = True
End Sub
Private Sub Command2_Click()
Command1.Value = True
End Sub
Ans. An out of stack space error will be displayed.
24. 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
[X] The code will execute without errors
[ ] An out of stack space error will be diplayed
[ ] The Computer will hang
[ ] ......
25. How to declare a DLL with a C Char datatype?
ByVal variable As Byte
26. What elements can you use in Conditional Compiling?
Ans. Literal Expressions
27. What event can handle when a user presess F2
Ans. KeyDown or KeyUp
Note : Not KeyPress because this event can only handle ASCII Keys ie A-Z,
a-z, 0-9
28. You want your UserControl to reflect the BackColor of the Container. What
will you use?
ans. AmbientProperties.
29. Your application contains the following class names Class1 with a
property named Myproperty. You run the following code
Dim A as Class1
Dim B as New Class1
B.Myproperty = 3
Set A = New Class1
How many instances of class1 exist after your run this code.
[ ] 0
[ ] 1
[X] 2
[ ] 3
30. Which argument of the ADD method is used to specify a node object to
Treeview ?( say creation of a Child )?
[ ]Key
[ ]Relative
[X]Relationship
[ ] ..........
31. You have a Label Control in USERCONTROL . If the user resizes the
usercontrol during run-time , in which event will you handle the resizing of
the label (so as to view the Label control)?
Ans. USERCONTROL_RESIZE
32. U have a Option Button inside a Frame on a Form. The Option ButtonÆs
HelpContextId is 0. If the user presses the F1 key, what will happen?
Frame's HelpContextId is searched for non-zero value and if so, help is
displayed.
33. If a user sets the LockEdits property of the Table to False and another
user updates the Table at the same time. What error will be displayed?
Ans. An Error message will be displayed when another tries to UPDATE a
record in the same page.
34. You have to indicate the property changes for an object. Which of the
following is best suited for the above scenario?
[ ] Property Get
[ ] property Let
[X] Public Sub()
[ ] Public Function()
35. U have 2 tables based upon which reports r to be generated by making use
of a common Field.
The existing Table structure and Report definitions should not be changed.
Which of the following is most appropriate.
[ ] create a new table and use Filter
[ ] Create a new table and use Sort
[X] create a new Dynaset using Filter
[ ] ......
36. How to create File option on menu with a Hot Key ALT F?
Ans. Set Caption to "&File" in Menu for that item
37. How do you pass a null pointer to a DLL?
Ans. Use vbNullString if you have declared the function to accept a string
argument OR
Declare the function to accept a long data type and tehn pass "0&" without
the quotes.
38. What files are generated by an internet component download setup?
Ans. A .cab file (component file and a .inf file) and a sample .htm file.
A directory called support is also generated which contains the component
file and also a .inf file.
39. A user complains that your control doesn't get downloaded saying that
Internet Explorer displays a message that it is unsafe for downloading the
control. What is the solution?
Ans. Ask the user to reduce his/her security settings until the error message
does not appear.
40. How will you allow users to edit your control at design time?
Ans. Set the EditAtDesignTime property of your UserControl object to True.
41. How do you make your User Control Object Invisible at run-time?
Ans. Set the InvisibleAtRuntime property of the UserControl object to True.
42. You are implementing Drag and Drop with a treeview control. What will you use in conjunction with DropHighlight?
Ans. HitTest
43. What property of the ProgressBar control specifies the current position?
[ ] Index
[X] Value
[ ] Range
[ ].....
44. How can you create a read-only property?
[X] Omit the Property Let procedure
[ ] Omit the Property Set procedure
[ ] Set its ReadOnly property to true
[ ] Use the Private keyword when declaring the procedure
45. You want a procedure to be visible only to objects in the current project
You want that this procedure should be accessible by external clients.
How will you declare the Procedure?
[ ] Private
[ ] Friend
[ ] Public
[ ] Static
46. You are observing variable1 in Procedure1 in the Locals Window.
Suddenly the Locals Window displays that the variable is "Out of Context"
when it enters Procedure2. How was variable1 declared?
[ ] As a Public in a standard Module
[X] As a Private variable in Procedure1
[ ] As a Private variable in Procedure2
[ ] As a Private variable in the General Section of the Form
47. You want that the code written for debugging should not be compiled.
How will you accomplish this?
[ ] Use If .. Then .. Else Staetments
[ ] Use the Err Object
[X] Use conditional compilation
[ ] .............
48. What is the advantage of specifying "Context" in the Watch Window?
1. You can add a watch to variables with the same name having different
scope
49. What can you do with menus created at run-time?
1. Create popup-manus with it
2. Delete the menus after using them
50. What controls can you place on an MDI Form?
Ans. The PictureBox and the Timer Controls
51. Which StatusBar property allows the display of common data such as date,
time etc?
[ ] Text
[X] Style
[ ] Object
[ ] SimpleText

Your Title