Thursday, July 17, 2008

vb questions 1

------------------------
2 You have created an ActiveX server which runs asynchronously. You wish to notify
clients of completion according to the clients' priority ranking. Which technique are
you going to use?

Choice 1 Broadcasts
Choice 2 Callbacks
Choice 3 Events
Choice 4 DataLinks
Choice 5 Notifys

----------------

--------------
4 Random
Sample

Rnd -1
Randomize 0


What is the effect of the two lines of code in the sample above on the Visual Basic
random number generator?
Choice 1 Generates an error because 0 is not a valid seed number for Randomize.
Choice 2 Guarantees the numbers generated are the same each time the program is run.
Choice 3 Tells Visual Basic to use the timer to help generate random numbers.
Choice 4 Has no effect at all.
Choice 5 Ensures that the numbers generated will be as random as possible.
answer 2

----------
5 What is the easiest way to make all the variables in a procedure static so they
retain their values between calls?
Choice 1 Add the Static keyword to the end of the declaration of the procedure. For
example, Sub Example() Static.

choice 2 Add the Static keyword to the beginning of the declaration of the procedure. For
example, Static Sub Example().

Choice 3 Explicitly declare each variable in the procedure Static.

Choice 4 Static procedures must all be kept in a single BAS module that has Option Static
in the Declarations section.

Choice 5 Set Option Static at the beginning of the procedure and Option Volatile at the end
of the procedure.

ANSWER--3
-----------
6 Sample
Code

Label1.Alignment = 0
Label1.Caption = "Hello World"

What is the result of the sample code above?
Choice 1 Syntax Error
Choice 2 Label1 snaps to the left edge of the form and displays "Hello World".
Choice 3 Label1 displays "Hello World".
Choice 4 Label1 snaps to bottom edge of the form and displays "Hello World".
Choice 5 Label1 snaps to the top edge of the form and displays "Hello World".
ANSWER--3
-----------------------
7 Sample
Code

Dim D As Date
D = #1/1/1#
D = D + 1
MsgBox Format$(D, FORMATSTRING)


What value of FORMATSTRING will cause the message box shown above to
display "2/1"?
Choice 1 "m/y"
Choice 2 "y/d"
Choice 3 "m/d"
Choice 4 "d/m"
Choice 5 "d/y"

answer 4

-------------
8 What happens when a Debug.Print statement is encountered in a compiled
program?

choice 1 In Windows NT, the output is directed to the Application Event Log instead of the
immediate window of the IDE.
Choice 2 In Windows NT, the output is directed to the System Event Log instead of the
immediate window of the IDE.

Choice 3 The output is directed to a file named form.LOG (where form is the name of the
active Form).

Choice 4 A message box is displayed if the program is compiled with the /DEBUG compiler
switch.

Choice 5 Nothing. Debug statements are ignored in compiled programs.
-----------------------
9 Sample
Code

Sub Main
Debug.Print Int(-99.2)
Debug.Print Fix(-99.2)
End Sub


When the sample code above is executed within the VB IDE, what is displayed in
the debug window?
Choice 1 -100
-100

Choice 2 -99
-100
Choice 3
-100
-99
Choice 4
-99
-99.20
Choice 5
-99
-99

answer --3

----------------------
10 How is it possible to accept more than one connection request using the WinSock
control?
Choice 1 WinSock1.Connections.Add

Choice 2 Microsoft's implementation of WinSock only supports a single connection.

Choice 3 WinSock1.Ports.Add

Choice 4 Set the WinSock1.Connections to a value greater than one.

Choice 5 Create a control array of WinSock controls.

ANSWER--5
---------------
11 In order to load chart data into an MS Chart from an array, what must be true?

Choice 1 The array must be a variant.

Choice 2 The array must be named DataGrid.

choice 3 The array must contain only integers.

Choice 4 The array must be smaller than 32K.

choice 5 That cannot be done.

ANSWER--3
----------------
12 Sample
Code

Dim x As Integer
Dim y As Long

For x = 1 To 32768
y = y + 1
Next x


The code above will produce an overflow error at run-time (not at compile time).
What is the value of y when the error occurs?
Choice 1

-1
Choice 2

0
Choice 3

32767
Choice 4

32768
Choice 5

The value of y is undefined
answer -----2

---------------
13 Sample
Code

For X = 1 To 5
Load Text1(X)
Text1(X).Text = X
Text1(X).Visible = True
Next X
Unload Text1(1)
Unload Text1(5)


In order for the sample code above to run, what must be true?
Choice 1

Text1 must exist with an index of 0.
Choice 2

Text1 must exist with an index of 0 and Dynamic = True.
Choice 3

Text1.Dynamic must = True.
Choice 4

Text1.IsArray must = True.
Choice 5

Text1 must exist with an index of 0 and IsArray = True.

answer---1

--------------------


14 What is the maximum length of the prompt string for a message box or input box?
Choice 1

80 characters
Choice 2

256 characters
Choice 3

512 characters
Choice 4

The prompt is limited only by the amount of available string space and the size of
the screen.
Choice 5

Approximately 1,024 characters depending on the width of the characters used.
answer------5
----------------

15
A progress bar displays the status of a long-running procedure. How do you
change the length of the bar to show current progress?
Choice 1

ProgressBar1.value = MyValue
ProgressBar1.Update
Choice 2

ProgressBar1.Value = MyValue
Choice 3

ProgressBar1.Current = MyValue
Choice 4

ProgressBar1.Length = MyValue
Choice 5

ProgressBar1.Interval = MyInterval
ProgressBar1.Update

ANSWER---2
------------------

16
What is the main difference between the Image control and PictureBox control?
Choice 1

The PictureBox is a lightweight version of the Image Control and only supports a
subset of the Image controls properties.
Choice 2

The ImageControl does not support JPEG images.
Choice 3

The Image control is a lightweight version of the PictureBox control and only
supports a subset of the PictureBox properties.
Choice 4

There is no difference. The Image control is provided for compatibility with older
versions of Visual Basic.
Choice 5

The Image control does not support a Click event.
ANSWER--3
------------------
17 Sample
Code

Dim WStr
WStr = List1.List(List1.ListIndex)


What does the sample code above do?
Choice 1

Syntax Error
Choice 2

It sets WStr to the value of the last item in List1.
Choice 3

It sets WStr to the value of the first item in List1.
Choice 4

It sets WStr to the value of the selected item in List1.
Choice 5

It sets the value of List1 to the value of WStr.
ANSWER--4
----------
18 Sample
Code

Sub Main()

Dim Main As String

Loop:

GoTo Main

Main:

Main = 45

End Sub


Although nobody should ever write code like the sample code above, which of the
following changes will allow this nasty to compile successfully?
Choice 1

Change 45 to "45".
Choice 2

Remove "Loop:".
Choice 3

Rename the variable to "Test" (all references).
Choice 4

Remove "Main:".
Choice 5

Change the name of the procedure from "Main" to "Test".

ANSWER 2
-------------
19 Sample
Code

Dim RS as Recordset

Set RS = DB.Openrecordset("Select * from Staff")

Dim Cnt as Long

Cnt = RS.RecordCount


Given the sample code above, what will Cnt contain?
Choice 1

The number of records in the resultset.
Choice 2

The number of records accessed so far.
Choice 3

The bookmark for the current record.
Choice 4

The number of unique records in the result set.
Choice 5

RecordCount is not valid for this type of recordset.
answer--1

--------------


20 To create an Addin for Visual Basic, you must have which of the following?
Choice 1

Visual Basic Enterprise Edition and Visual C++
Choice 2

Visual Basic and Visual C++
Choice 3

Visual Basic
Choice 4

Visual Basic Control Creation Edition
Choice 5

Visual Studio


----------
21 Sample
Code

Sub Main()

Dim i As Long
i = 3

Debug.Print i
DoSomething i
Debug.Print i

End Sub

Sub DoSomething(i As Long)
i = i ^ 2
End Sub


When the sample code above is run in the IDE, what will be displayed in the debug
window?
Choice 1

3
3
Choice 2

3
9
Choice 3

3
0
Choice 4

3
error: the value of i is undefined
Choice 5

Compilation error: The value of 'i' can't be changed by FooBar().
ANSWER ------2
------------
22 Sample
Code

Timer1.Style = vbanalog
Timer1.visible = True
Timer1.UpdateInterval = 1


You have a form with a timer control on it, and the timer is named Timer1. What
does the sample code above do?
Choice 1

Displays a digital counter which updates on a one second interval.
Choice 2

Displays an analog watch which updates on a one second interval.
Choice 3

Displays an analog watch which updates on a one minute interval.
Choice 4

Displays an analog watch which does not update until you execute Timer1.Start.
Choice 5

None of the above
ANSWER----5

----------
23 Sample
Code

Dim clmX As ColumnHeader
Set clmX = ListView1.ColumnHeaders. Add(, , "Company", ListView1.Width / 2)
Set clmX = ListView1.ColumnHeaders. Add(, , "Address", ListView1.Width / 2)


You have a Listview control on your form. What must you do to get the column headings as defined in the
sample code above to appear?
Choice 1

ListView1.View = lvwSmallIcon
Choice 2

ListView1.View = lvwIcon
Choice 3

ListView1.View = lvwReport
Choice 4

ListView1.View = lvwList
Choice 5

ListView1.View = lvwGrid
ANSWER--3
------------------
24 What is NOT a good use for the Sysinfo Control?
Choice 1

To determine the size of the desktop minus the task bar.
Choice 2

To get notified of color depth changes.
Choice 3

To get the OS Version.
Choice 4

To get the logon name.
Choice 5

To get notified when a new device is added to the system.

--------------------
25 What is an rdoConnection equivalent to in DAO?
Choice 1

Datasource
Choice 2

WorkSpace
Choice 3

Engine
Choice 4

Recordset
Choice 5

Database
ANSWER--5
------------------
26 On a status bar, how do you get the panels to resize with the rest of the form?
Choice 1

StatusBar1.Panel(1).Type = sbrSpring
Choice 2

StatusBar1.Panels(1).Style = sbrSpring
Choice 3

StatusBar1.Panels(1).AutoSize = sbrSpring
Choice 4

StatusBar1.Panels(1).Type = sbrSpring
Choice 5

StatusBar1.AutoSize = sbrSpring
ANSWER-----4
-----------------
27 In which order do the events occur on a shape control when clicked by the mouse?
Choice 1

Got Focus, Mouse Down, Mouse Up, Click
Choice 2

Mouse Down, Got Focus, Mouse Up, Click
Choice 3

Got Focus, Mouse Down, Click, Mouse Up
Choice 4

Mouse Down, Got Focus, Click, Mouse Up
Choice 5

None of the above
ANSWER--5

-----------------
28 Client A connects to Remote OLE server B. OLE server B connects to OLE server
C on a second server. Remote creates are allowed on all servers by ACL. Server B
has permission to run server C. Client A only has permission to run server C. What
happens?
Choice 1

Client A succeeds because Server B has needed security.
Choice 2

Client A must add user information to the automation request.
Choice 3

Client A fails because he lacks permission to server B.
Choice 4

Client A fails because security is passed.
Choice 5

Client A receives a logon dialog.
---------------------
29 How do you determine which tab on a TabStrip control has been selected?
Choice 1

Examine the TabIndex property of the TabStrip control.
Choice 2

Examine the Index argument passed to the TabStrip TabClick event.
Choice 3

Examine the Index argument passed to the TabStrip Click event.
Choice 4

Examine the SelectedItem property of the TabStrip control.
Choice 5

Examine the TabStrip1(n).Selected property (in a loop) for each of the 'n' tabs.
ANSWER--4
-------------------


--------------------
31 How do you group related controls for each tab when using Microsoft's Tab control?
Choice 1

Use a frame control on the tab to contain the controls and manually switch visibility
based upon the tab selected.
Choice 2

Draw the items on the tab.
Choice 3

Use an image control to contain the controls and manually switch visibility based
upon the tab selected.
Choice 4

Use the properties dialog of the Tab Control and choose the controls for each tab
from the listbox.
Choice 5

Select the items for a tab and set the Parent property to the tab index.
ANSWER--2
-------------------
32 When does VB free an object from memory?
Choice 1 When the object variable is set to nothing.

Choice 2 When all references to the object have been destroyed.

Choice 3 When your program executes an End statement.

Choice 4 When the Release method is called.

Choice 5 It's impossible to tell using VB since it maintains the reference counts.
ANSWER--1
-------------------
33 You have a scroll bar on your form. When the user clicks on the end arrows, which
event occurs?
Choice 1 Slide
Choice 2 Click
Choice 3 Scroll
Choice 4 Update
Choice 5 Change

ANSWER--5
-----------------
34 Which DAO Recordset property indicates your current record position in the
RecordSet?
Choice 1 Index
Choice 2 RecordCount
Choice 3 RecordPosition
Choice 4 AbsolutePosition
Choice 5 RecordIndex

ANSWER--4
----------------
35 What Recordset method can be used to make a duplicate Recordset to allow you
to have multiple current records?
Choice 1 Set rs2 = rs1.Duplicate()
Choice 2 Set rs2 = rs1.Copy()
Choice 3 Set rs2 = rs1.Clone()
Choice 4 Set rs2 = rs1.Snapshot()
Choice 5 No special method exists or is required. Just use: Set rs2 = AddressOf rs1

ANSWER--3

Your Title