Thursday, July 17, 2008

vb questions 10

Q: Why would you want to set the LockEdits property to False?
A: Optimistic locking is in effect for editing. The 2K page containing the
record is not locked until the Update method is executed.
What kind of error is the most expected with optmistic lock? Data changed;
operation stopped
If recordset.lockedits=false, which would be the most like to occur:
A. update error: record locked on by *
B. save error: record locked on by
C. can not read database...
Incorporate dynamic-link libraries (DLLs) into an application.
•Declare and call a DLL routine.
Q: How to declare a DLL with a C Char datatype?
A: ByVal variable As Byte
Declare Function Publicname Lib "libname" [Alias "alias"] [Arguments List]
As Type
Empty value ByVal 0&, vbNullString
Char ByVal a As Byte
Asciiz String ByVal as String
There are 2 deferent DLL from 2 vendors and the DLL have the same name.
What must you do to be able to call both functions?
A. modify function name in one
B. declare public in separate module use the alias keyword to
C. declare private rename one function *
D. Use the alias keyword to rename one function *
We obtained many DLL functions from different vendors. Two functions happen
to have the same name but different purposes. What can we do?
A. Using an alias *
B. Declaring each Private in separate modules *
C. Registering one with another name
D. Modifying the DLL function.
Pass argument contain address of a Vb subroutine named MyProc to a MicWind
HPL
A. Aressof := MyProc
B. Adressof Me.MyProc
C. Adressof MyProc *
D. Adressof (MyProc)
Which code will create a new instance of object named Form1 in Project1?
A. Dim Frmx As Form1
B. Dim Frmx As New Form1 *
C. Set Frmx = Form1
D. Set Frmx = GetObject("Project1.Form1")
How many instances of class1 after running exist after the following code?
Dim a As Class1
Dim b As new Class1
b.MyProperty = 3
Set a = new Class1
A. 0
B. 1
C. 2 *
D. 3
In which case is a new object created? set x=new form1
Which Option will not allow to create instances : set Public to FALSE
Create an Automation server that exposes objects, properties, methods, and
events.
Q: The differences between early binding vs. late binding
•A: 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.
Which two required for Early Binding?
A. Type library *
B. Dual Interface
C. New Keyword *
D. CreateObject Function
For Early Binding
Dim Varnaem as Class
Set varname = CreateObject(ClassName)
Create and use an ActiveX control.
•Declare and raise events.
How to raise an event?
First to declare it, use the Event keyword, then Raise it.
e.g. RaiseEvent ABC (arguments)
How Project Groups can be used when debugging ActiveX controls(lots of Qs).
Ambient & Extender
What is the property of a container that can be used to change the
background color of the control on the container when the background color
of the container changes?
A. Ambient *
B. Extender
C. Appearance
D. Property Pages
How do you create a license package file containing the licensing
information for all controls on a Web page?
A. With the Visual Basic License Manager.
B. With the CODEBASE parameter of an HTML page'stag.
C. With the Visual Basic Application Wizard.
D. With a utility from the LPK_TOOL directory on the Visual Basic CDROM. *
Q: How to add a control to a web page?
A: By scripting
You want to minimize download time for an ActiveX document with several
components. How package within a .cab file?
In a single .cab file
One .cab with ActiveX document. And a second .cab with referenced components
One .cab with ActiveX document and an INF file that points to individual cab
files for each component. *
One .cab with ActiveX document, an INF file that points to a .cab file with
the referenced components
Q: How to reduce the time for downloading on Internet an ActiveX component?
A: Create separate secondary .cab files ???
Users may already have these secondary .cab files on the system or the
secondary .cab files can be downloaded from Microsoft's web site.
Which two project types can contain an ActiveX Document?
A. Standard EXE
B. ActiveX Document EXE *
C. ActiveX Document DLL *
D. ActiveX Control
Q: What project types can have ActiveX documents?
A: All that can be a container
Q: How to convert an ActiveX.DLL to multithread?
A: Make it ActiveX. EXE
Q:Advantages of Using ActiveX Documents (Choose 2).
Q: What elements of ActiveX Components on a Web page contribute to security?
•A: When you use ActiveX controls on a Web page, you can implement the
following security measures:
•Set the appropriate level of security in Internet Explorer
•Provide users with information about the author of the control
•Through digital codesigning
•Create an Internet download by marking your Controls as safe for
scripting and initialization
Which project template would you select to build an in-process code
(ActiveX Document DLL)?
Hyperlink object
Which 2 actions may disqualify a component for being marked as safe for
scripting?
A. the component creates a password
B. the component writes information to a file
C. the component inserts data in registry *
D. the component reads information from registry *
Q: 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?
A1: No Internet download license file on the web server
A2: Options in the Application Setup Wizard were not used correctly
What ActiveX can do on WWW?
A. create licensing files
B. digital signing
C. register your control on a user’s computer *
D. modifying the users internet security settings
If you want to offer an option in a help menu for users to access your Web
Site, what ActiveX Document should you use?
A. Automation
B. WinSock
C. Hyperlink *
D. ActiveX component
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?
A. Files
B. Byte arrays
C. Pictures
D. Hyperlinks *
What is the purpose of the ID parameter in an HTML tag?
A. Specifies a URL that points to a file containing an implementation of an
object.
B. Specifies the object's unique class identifier stored in the system
registry.
C. Specifies a URL that points to the name of the object.
D. Specifies the object name. *
An ActiveX component connects to a database, the connection to the database
fails. What to do?
A. Create an error event
B. Set err object to false
C. Call raise method of the err object *
D. Create a prop name connected that returns false
Q: An error occurs in a component that you wrote, how to notify client:
A: Err.Raise number
Which property of the Err object returns the name of the object that
generated an Error?
A. Description
B. Source *
C. Number
D. Helpcontext
Q: Which code segment would best trap a "division by zero" error handling?
A: For example: (See Error Handling)
•Public Sub ProcDivZero()
On Error GoTo ErrTrapper
X = 100 / 0
Exit Sub
End Sub
ErrTrapper:
If Err.Number = 11 Then Debug.Print "Division by Zero Found"
End Sub
When the following code executes. What will the user see?
•Public Sub MyTest()
On Error GoTo ErrHandler
Dim X as Integer
MyProc(X)
MsgBox "XXX"
Errhandler:
MsgBox "YYY"
End Sub
Public Sub MyProc(X As Integer)
On Error GoTo MyprocErr
X = X / 0
MyprocErr:
MsgBox "ZZZ"
End Sub
a) "XXX" Only
b) "ZZZ" Only
c) "XXX", "ZZZ" and "YYY" Only *
d) "XXX" and "ZZZ" Only
Q: 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
A: OUt of Stack Space error
Q: 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
A: The code will run OK
Implement Help features in an application.
You want to use the ShowHelp method to display specific Help file pages for
your application without declaring a dll. Which object?
A. App
B. Menu
C. MenuLine
D. CommonDialog *
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.
CommonDialog1.ShowHelp
HelpcontextID set to 0 for an option Button in a Frame, what will happen
when press F1?
A. Help conexts page is displayed
B. HelpContextID property of form is evaluated
C. HelpContextID property of the frame is evaluated *
D. Context help for the Option Button control is displayed.
Form’s HelpContextId is searched for non-zero value and if so, help is
displayed for the Form
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.
Debugging and Testing Issues


Select appropriate compiler options.

•List and describe options for optimizing when compiling to native code.
•List and describe the differences between compiling to p-code and
compiling to native code.
What code will have the most to gain on to be compiled to Native Code?
A. Code that uses windows API
B. Code that has much String functions
C. Code that manipulates objects
D. Code that have complex Financial calculations *
Your application relies on arguments that are passed by reference. Which
two native code compilation options should you select to optimize the
performance of numeric processing?
A. Assume no Aliasing
B. Optimize for small code
C. Remove VB floating point error checks *
D. Remove Safe Pentium FDIV checks *
You are creating an application that is intended to run on only PentiumPro
based servers. You want to maximize the performance of this application.
Which compiler option should you use?
A. Assuming no Aliasing
B. Optimize for small code
C. Create symbolic debug information
D. Remove safe for Pentium FDIV checks *
You want the code written for debugging should not be compiled. How will
you accomplish this?
A. Use If .. Then .. Else Statements
B. Use the Err Object
C. Use conditional compilation *
Which element can you use in a conditional compilation directive?
A. Public variable
B. Public constant
C. Literal expression *
D. Undefined constant
Creating an application that uses conditional compilation to enable and
disable elements of functionality, which two mechanisms can you use to set
conditional compilation constants?
A. Dim statement
B. Constant statement
C. #Constant directive *
D. Project property dialog box *
Q: Where do you define conditional compiling variables?
A: Command line
Project Properties dialog box (under the Make tab)
In code
Conditional compiling could be used to:
1.designing an application to run on different platforms
2.changing the date and currency display filters
3.Remove debug code
What expression is acceptable for #const Only literal and their operation
except Is


Set watch expressions during program execution.
Q: When can you add watch variables?
A: In Break and design mode
Two advantages of using the context options in the Add watch dialog box are.
A. Allow multiple projects scope
B. Allow faster evaluation of expressions by narrowing content (of context) *
C. Increase number of break mode options
D. Viewing variables that have the same name but different scope *
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.
Monitor the values of expressions and variables by using the debugging
windows.
Which variable does the local window show? (select 2)
A. All variables within a module
B. All variables within your Application
C. All variables within the Current procedure *
D. All object variables within the current scope *
Which task(s) can you perform by using the locals window
A. Edit the call stack
B. Define new variables
C. View and change expressions
D. View and change variables of the current procedure *
Which three task can you perform by using the immediate window in break mode?
A. declaring a variable as object
B. declaring a function
C. executing a function *
D. executing the call stack
E. view the value of the variable *
F. changing the value of the variable *
Immediate window: A control structure is valid only if it can be completely
expressed on one line of code, use colons to separate the statements.
You want to find out when a variable changes to a new value. Which tool would
you use?
- Watch window
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?
A. As a Public in a standard Module
B. As a Private variable in Procedure1 *
C.As a Private variable in Procedure2
D. As a Private variable in the General Section of the Form
You want to test the Unload behavior of an In-Process component.
What should you do?
A. Start another instance of the development environment and create a test
project that references the component.
B. Create a project group that contains both a test project and the component
*
C. Add debug statements to the DLL component
D. Call the free library function in the MS Windows API
A control to be used by all programmers in a company. You need debug control:
interaction with the same process as one of your applications. How to do?
A. add control project to your app project *
B. load control project in second instance
C. in the app proj add a reference to control project
D. in the control proj add a reference to app project
•Q: What is the difference between debugging an ActiveX control project and
an in-process component?
A: The component code can run while the client is in Design mode
•Q: When testing a UserControl, you add a standard.exe to your project group.
UserControl in the Toolbox is dimmed. What should you do?
A: Close the UserControl designer and then test again
What should you do to debug an out of process component?
A. Start a second instance of the development environment *
B. Compile the component by using symbolic debug information
C. Create an error handler for the out of process component
D. Create a project group
Define the scope of a watch variable.
How to view contents of the Variant?
A. Use Debug.print *
B. Use Object browser
C. Look at the Locals window *
D. Copy to Clipboard
Create a setup program that installs and registers ActiveX controls.
Manage the Windows system registry.
pplication-specific information in the registry. •Register components
by using the Regsvr32.exe utility. •Register components by using the Remote
Automation Connection Manager. •Edit the registry manually. •Register a
component automatically.
Save settings?
A. local_Machine
B. current_User *
C. Current_Config
D. Classes_Root
IIS can not instantiate an object provided by the DLL (ActiveX) What should
you do to the DLL?
A. Digital Sign it
B. Mark as safe for initialize
C. Mark as safe for scripting
D. Register by Regsvr32 utility *
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?
REGSRV32.EXE
Q: How to use Regsvr32.exe to install ActiveX DLL, EXE, OCX?
A: To install ActiveX.dll - Regsvr32 dllname
To install Activex.Exe - AX_exename /Regserver
MSDN Deploying ActiveX Controls on the Web with the Internet Component
Download
DeSigning Controls for Use with HTML
Which task can you accomplish by packaging in .cab file?
A. creating license file
B. digital sign it
C. register on users computer *
D. modifying users internet security settings
Q: What cannot be done when an Internet Control is packaged. (Choose Two)
A: Write to a file
Read from the registry
Q: How can you build ActiveX components for Internet distribution?
A: Use the Application Setup Wizard and pick the appropriate options
Q: What type of files does the Setup Wizard generates for Internet download
setup? *.CAB files.
------------------------------------------------------------------------
Q: Which function can the Setup Wizard of the Enterprise Edition of VB 5
perform in addition to installing your ActiveX EXE project?
A: install your project as an ActiveX shared component
Q: What does locales show in different contexts?
A: In Visual Basic, many functions use the user's system locale, which uses
the Control Panel settings provided by the operating system to automatically
determine the conventions at run time. These functions are called
What is the event trigger sequence? Initialize, Load, Resize, Activate,
Paint
How to add the column to a ListView? MyListView.ColumnHeaders.Add ,,
"MyNewCol"
A unique feature of the Report view is ColumnHeader objects. The ListView
control contains a collection of ColumnHeader objects in the ColumnHeaders
collection.
For which control does the ImageList control act as a central repository of
images? ListImage
An ImageList control contains a collection of ListImage objects, each of
which can be referred to by its index or key.
Set pnlX = StatusBar1.Panels.Add() ' Add a new Panel object.
Set pnlX.Picture = ImageList1.ListImages(1).Picture ' Setting Picture must
use set.
What Property will you use to access BUTTONS of TOOLBAR? Key & Index
StatusBar1.Style property allows the display of common data such as date,
time, etc.
Insert text to Statusbar SB1 Second panel- SB1.panels(2).text = "text"
Your application has just deleted a record from a dynaset-type Recordset.
What is the current record? The delete record.
Which properties of the data control can be changed at run time? Recordset,
databasename, recordsource
The data in the currently selected row can be accessed using the Bookmark
property, which provides access to the underlying Recordset object’s current
record.
Which type of recordset you will use to populate country names into a
istBox? Forward-only
Which recordset you will use to find a record in multi-user environment?
Dynaset
recordset.{FindFirst | FindLast | FindNext | FindPrevious} criteria .
criteria likes the WHERE clause.
Which two project types can contain an ActiveX Document? ActiveX Dll,
ActiveX Exe.
What project types can have ActiveX documents? - All that can be a container
How to convert an ActiveX.DLL to multithread? - Make it ActiveX. EXE
Advantages of Using ActiveX Documents - Support for the Hyperlink object and
AsyncRead method
Which project template would you select to build an in-process code
(ActiveX Document DLL)?
The AsyncRead method initiates an asynchronous download.
Datatypes to be downloaded: files, pictures, byte arrays
Which 2 actions may disqualify a component for being marked as safe for
scripting? inserts in/reads from registry
ID parameter in an HTML tag specifies the object name.
When an error occurs in a component, call Err.Raise number.
Err.Source returns the name of the object that generated an Error.
Command1_Click() AND Command2_Click() call each other - Out of Stack Space
error
Before you use the CommonDialog.ShowHelp method, you must set the HelpFile
and HelpCommand properties.
If HelpContextID is set to 0, then Visual Basic looks in the HelpContextID
of the object's container.
Financial calculations will have the most to gain on to be compiled to
Native Code.
Optimize the numeric processing performance - Remove VB - Remove FDIV
Literal expression can be used in a conditional compilation directive.
How to set conditional compilation constants - #Constant directive,
Project property dialog box
When can you add watch variables? - In Break and design mode
You can restrict the scope of variables in watch expressions to a specific
context. Visual Basic can evaluate a variable in a narrow context more
quickly.
Locals window - View and change variables of the current procedure
Immediate window - executing a function, view or change ariable
Test behavior of an In-Process component - Create a project group
Debug an out of process component - Start a second instance of IDE
Save settings in – Hkey_current_User
Find out about the components that are registered in that computer -
REGSRV32.EXE
To install ActiveX.dll - Regsvr32 dllname
To install Activex.Exe - AX_exename /Regserver
Which task can you accomplish by packaging in .cab file? register on users
computer
Q: 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?
A1: No Internet download license file on the web server
A2: Options in the Application Setup Wizard were not used correctly
Q: Where do you define conditional compiling variables?
Command line
•Q: Difference between debugging an ActiveX control project and an
in-process component

Your Title