Thursday, July 17, 2008

vb Questions 3

1 Sample
Code

MsgBox Hex$(RGB(63,127,255))


What will be displayed by the message box when the sample code above is
executed?
Choice 1

3F7FFF
Choice 2

FF7F3F
Choice 3

FFFFFF
Choice 4

631225
Choice 5

A runtime error, the value returned by RGB() is too large to be represented in HEX.
ANSWER--2
----------------


--------------
3
Named
Arguments

Named x:=1, y:=1


When can you call one of your procedures with named arguments as shown in the
example above?
Choice 1

When either x or y has been declared as Optional.
Choice 2

When neither x or y has been declared as Optional.
Choice 3

When both x and y have been declared as Optional.
Choice 4

Any time, as you can always used named arguments.
Choice 5

Never, as this is a feature of VBScript not VB.
ANSWER--5

----------------
4 Staff Table
Layout

EmpName Char(30)
DOB Date
Rank Integer
Comment Memo
Salary Currency


What SQL command(s) should be used to delete all employees with salaries over
$50,000 in the Access table shown in the sample above?
Choice 1

Delete Staff Where Salary > 50000
Choice 2

Delete From Staff Where Salary > 50000
Choice 3

Select * From Staff Where Salary > 50000
Delete
Choice 4

Delete * From Staff Where Salary > 50000
Choice 5

Select From Staff Delete Where Salary > 50000

-----------------
5 Sample
Code

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


What is the result of the sample code above?
Choice 1

Label1 snaps to the left edge of the form and displays "Hello World".
Choice 2

Label1 displays "Hello World".
Choice 3

Label1 snaps to bottom edge of the form and displays "Hello World".
Choice 4

Syntax Error
Choice 5

Label1 snaps to the top edge of the form and displays "Hello World".
------------------

6 How does setting the PasswordChar property of a TextBox control to "#" affect the
behavior of the control?
Choice 1

Replaces each character displayed in the TextBox with "#".
Choice 2

Replaces each character displayed in the TextBox with "*".
Choice 3

It doesn't affect the control at all. You have to set the PasswordChar property to
"*".
Choice 4

Replaces each digit displayed in the TextBox with "#".
Choice 5

Replaces each digit displayed in the TextBox with "*".

--------------
7 What event is triggered by a Timer Control?
Choice 1

Interval
Choice 2

Tick
Choice 3

Timer
Choice 4

Activate
Choice 5

OnTime
--------------------
8 To print the contents of a textbox named Text1 to the debug window you use which
code?
Choice 1

debug.print Text1.Caption
Choice 2

debug.print Text1.Text
Choice 3

debug.print Text1.Value
Choice 4

debug.print Text1.Content
Choice 5

debug.print cstr(Text1.Value)

------------------
9 Sample
Code

Dim C as Control

For Each C in Me.Controls
If Len(C.Text) < 5 then
C.ToolTipText = "Entry too Short"
End If
Next


Your form contains 3 labels and 3 Text boxes. What is the result of the sample
code above?
Choice 1

All controls for which the length of the text property is less than 5 have their
ToolTipText set to "Entry to Short".
Choice 2

A runtime error occurs.
Choice 3

All controls for which the length of the text property is less than or equal to 5 have
their ToolTipText set to "Entry to Short" only if ShowToolTips is set to True.
Choice 4

All controls for which the length of the text property is less than 5 have their
ToolTipText set to "Entry to Short" only if ShowToolTips is set to True.
Choice 5

All controls for which the length of the text property is less than or equal to 5 have
their ToolTipText set to "Entry to Short".

------------------
10
You have created a class which you would like to share with the other members of
your project team. The methods in the module should be accessible like the
members of the VB App object. How do you set the Instancing property of the
class?
Choice 1

MultiUse
Choice 2

SingleUse
Choice 3

Private
Choice 4

PublicNotCreatable
Choice 5

GlobalMultiUse

-----------------
11
How do you ensure that no matter how large the bitmap is, your picture box named
Pic1 will always show the entire bitmap?
Choice 1

Pic1.Autosize = True
Choice 2

Pic1.Scalemode = vbAuto
Choice 3

Pic1.Scalemode = vbStretch
Choice 4

Pic1.Height = Pic1.ImageHeight
Pic1.Width = Pic1.ImageWidth
Choice 5

Pic1.Stretch = True
---------------------
12
How do you determine the position of the currently selected item in a ComboBox
called ComboBox1?
Choice 1

ComboBox1.SelectedItem
Choice 2

ComboBox1.Index
Choice 3

ComboBox1.ListItem
Choice 4

ComboBox1.ListIndex
Choice 5

ComboBox1.Selected

--------------
13
Array
Sample

Dim Arr() As Variant
' array is populated here
UBound(Arr)


What is the purpose of the Ubound function in the sample above?
Choice 1

Determines the highest value in the array, Arr.
Choice 2

Returns the highest allowable value that can be stored in the array, Arr.
Choice 3

Returns the highest index in the array, Arr.
Choice 4

Determines how much memory the array, Arr, is currently using.
Choice 5

Determines the maximum amount of memory reserved for the array, Arr.

----------------
14 Type statements must appear in what part of a module?
Choice 1

In a separate .TLB file so they are visible to all modules.
Choice 2

Inside the procedure where they will be used.
Choice 3

In the Sub Main or Startup Form.
Choice 4

In the declarations section of the module.
Choice 5

In the Initialize Event of a class module.

--------------
15 Sample
Code

Sub Main()

Dim i As Long
Dim v As Variant

v = DoSomething(4)

For i = LBound(v) To UBound(v)
Debug.Print v(i);
Next i

End Sub

Function DoSomething(ByVal N As Long) As Variant

Dim i As Long
Dim v() As Variant

ReDim v(N)

For i = 0 To N
v(i) = i
Next i

DoSomething = v

End Function


When the sample code above is run in the VB IDE, what is printed in the debug
window?
Choice 1

1 2 3 4
Choice 2

0 1 2 3
Choice 3

0 1 2 3 4
Choice 4

1 2 3 4 5
Choice 5

runtime error: subscript out of range

----------------
16 Sample
Code

Dim X As Integer
X = 1.5 + 1.4


Given the sample code above, what is the value of X?
Choice 1

1.51.4
Choice 2

2
Choice 3

2.9
Choice 4

3
Choice 5

30
----------
17
Mid Function

Mid$(s, 4, 1) = "X"


What is the effect of executing the line shown above?
Choice 1

The first four characters of the string, s, are replaced by "X"s.
Choice 2

The fourth character of the string, s, is replaced by an "X".
Choice 3

A runtime error is generated. Mid$ is used to extract substrings.
Choice 4

The first character of the string, s, is replaced by an "X".
Choice 5

The string, s, is not changed.

----------------
18

How can a Masked Edit control be used to guarantee that bad dates are not
permitted?
Choice 1

Set MaskedEdit1.Mask to "##-##-####" and place code in the Validate event to
disallow non-date data.
Choice 2

Set MaskedEdit1.Mask to "##-##-####" and place code in the KeyPress event to
disallow non-date values in the field.
Choice 3

MaskedEdit1.Mask = "##-##-####"
Choice 4

MaskedEdit1.Mask = "99-99-9999"
Choice 5

Set MaskedEdit1.Mask to "##-##-####" and place code on form load event, Check
MaskedEdit.text with IsDate to disallow non-date data.

-----------------
19 How can you make VB automatically continue when a runtime error is detected?
Choice 1

App.BreakOnErrors = False
Choice 2

Use "On Error Resume Next" at the beginning of every function.
Choice 3

Use "On Error Continue" at the beginning of every function.
Choice 4

Set the "Break On All Errors" to False in the IDE before compiling.
Choice 5

Use "On Error Goto 0" at the beginning of every function.

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

You have started a transaction using DAO. You decide that an error has occurred
which requires backing out all updates. What command do you issue?
Choice 1

CommitTrans = False
Choice 2

RollBack
Choice 3

BackOut
Choice 4

CancelTrans
Choice 5

DAO does not support transactions.
-------------------
20
Sample
Code

Dim X as Integer
X = 3 + 7 * 5 - 2


Given the sample code above, what is the value of X?
Choice 1

13
Choice 2

24
Choice 3

30
Choice 4

36
Choice 5

48

----------------------
21

Sample
Code

Label1.Caption = "E&xit"


What is the purpose of the sample code above?
Choice 1

To set the shortcut key combination to Shift-E.
Choice 2

To set the shortcut key combination to Cntl-X.
Choice 3

To set the shortcut key combination to Alt-X.
Choice 4

To set the shortcut key combination to Cntl-E.
Choice 5

To set the shortcut key combination to Alt-E.

---------------
22 Which DAO Recordset property indicates your current record position in the
RecordSet?
Choice 1

RecordPosition
Choice 2

RecordCount
Choice 3

AbsolutePosition
Choice 4

RecordIndex
Choice 5

Index

-----------------
23 What is the primary difference between a TabStrip control and the Tabbed Dialog
control?
Choice 1

The TabStrip supports pictures on the tabs.
Choice 2

The Tabbed Dialog supports pictures on the tabs.
Choice 3

The TabStrip is not a container control.
Choice 4

The Tabbed Dialog is not a container control.
Choice 5

The name is the only real difference.

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

Engine
Choice 2

WorkSpace
Choice 3

Recordset
Choice 4

Database
Choice 5

Datasource

-------------------
25
You have an OLE Container control on your form. The user has inserted a Word
Document at runtime. How will you save this file?
Choice 1

OLE1.FileName = "C:\Test.OLE"
OLE1.Save
Choice 2

OLE1.ActiveDoc.Save
Choice 3

OLE1.SaveToFile "C:\Test.OLE"
Choice 4

OLE1.SaveToFile 1
Choice 5

OLE1.FileName = "C:\Test.OLE"
OLE1.Save oleOverWrite

-------------
26 Sample
Code

Dim Wdate as Date

Wdate = CDate(Text1.Text)


Assume the Windows short date is set to its default of "m/d/yy". In the sample
code above, if Text1 contains 06/19, what does Wdate contain on the date
7/4/1999?
Choice 1

06/19/99
Choice 2

06/19/00
Choice 3

06/19
Choice 4

06-19
Choice 5

An Invalid Date error occurs.

-----------------
27 How do you add a Help button to a VB message box (MsgBox)?
Choice 1

Set the vbShowHelpButton flag in the buttons parameter to the MsgBox function.
Choice 2

Make sure that the first character in the prompt string is a ? (question mark)
character.
Choice 3

This can't be done using MsgBox. You have to create a custom message box
using a form.
Choice 4

Set the vbMsgBoxHelpButton flag in the buttons parameter to the MsgBox
function.
Choice 5

Just include values for the HelpFile and Context parameters and MsgBox will
display the button automatically.

----------------
28
How do you indicate to the OLE Container control whether the object will appear as
an icon or if the object's content will be displayed in the control?
Choice 1

Set the OLE Container's Type property to 0 for content and 1 for icons.
Choice 2

Set the OLE Container's DisplayType property to 0 for content and 1 for icons.
Choice 3

Set the CreateEmbed property to False (for icons) and True (for data).
Choice 4

Set the OLE Container's Display property to 0 for content and 1 for icons.
Choice 5

Set the Style property to 0 for content and 1 for icons.

---------------
29
How can you prevent a form from unloading before a specific action has taken
place?
Choice 1

Set the Cancel argument of the QueryUnload event to True.
Choice 2

This cannot be done in VB; you have to use a Windows API call.
Choice 3

Set the Form BorderStyle to None.
Choice 4

Set the QueryUnload property of the Form to True.
Choice 5

Set the ManualUnload property of the Form to True.
----------------
30
You use an OLE automation to develop your application and wish to interface with
Excel. What must be true in order for the auto-complete function of the IDE to
work?
Choice 1

Excel must be running.
Choice 2

Excel must be installed in the path.
Choice 3

You must use late binding.
Choice 4

Your project must have a reference to the Excel object library.
Choice 5

You must add MSEXCEL.TLB to your project using the Project, Add Typelib menu.
------------------
31 What is the Preserve option on the ReDim statement used for?
Choice 1

To preserve the contents of a string when you change its size.
Choice 2

To preserve the size of an array so items can't be deleted accidentally.
Choice 3

To preserve the contents of an array when you are expanding it.
Choice 4

To preserve the case of a string when you change its size.
Choice 5

To prevent VB from resizing arrays automatically to save space when free memory
is getting low.
----------------
32 Sample
Code

If TypeOf MyControl Is CommandButton Then
Debug.Print "CommandButton"
End If


How would you represent the If statements above using a Select Case clause?
Choice 1

Select Case TypeOf(MyControl)
Case CommandButton : Debug.Print "CommandButton"
End Select
Choice 2

Select Case TypeOf MyControl
Case CommandButton : Debug.Print "CommandButton"
End Select
Choice 3

Dim v As Variant
v = TypeOf MyControl
Select Case v
Case CommandButton: Debug.Print "CommandButton"
End Select
Choice 4

TypeOf can't be used with Select Case.
Choice 5

Select Case TypeOf MyControl
Case Is CommandButton : Debug.Print "CommandButton"
End Select

----------------
33 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 first item in List1.
Choice 3

It sets the value of List1 to the value of WStr.
Choice 4

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

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

--------------
34 Sample
Code

Frame1.Visible = True
Frame1.Enabled = False
ChkBox1.Enabled = True
ChkBox2.Enabled = True
ChkBox3.Enabled = True


In the sample code above, Frame1 contains 3 checkboxes. What happens when
the user clicks on ChkBox1?
Choice 1

Syntax Error
Choice 2

A message box shows a standard VB error.
Choice 3

Nothing happens.
Choice 4

The value is toggled from unchecked to checked and the others are switched to
checked.
Choice 5

The value is toggled from unchecked to checked.

----------------
35 Sample
Code

Dim X As Double
Dim Y As Integer
X = 1.056
Y = X
X = Y


Given the sample code above, what is the value of X?
Choice 1

1
Choice 2

1.056
Choice 3

1.06
Choice 4

1.56
Choice 5

2

--------------
36 Sample
Code

Text1.Tabstop = False


What is the effect of the sample code above?
Choice 1

It prevents the user from using the tab key to enter Text1.
Choice 2

It prevents the user from modifying Text1.
Choice 3

It prevents the user from selecting Text1.
Choice 4

It allows the user to use the Tab Key in Text1.
Choice 5

It prevents the user from using the tab key in Text1.
---------------------
37 What looping construct is used to test the loop termination condition at the end of
the loop?
Choice 1

If Then
Choice 2

Do Loop Until
Choice 3

While Wend
Choice 4

For Next
Choice 5

VB does not provide a construct to accomplish this.

Your Title