News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Important & Frequent VB Questions & Answers

Started by Kalyan, Jul 16, 2008, 03:40 PM

Previous topic - Next topic

Kalyan

Important & Frequent VB Questions & Answers

1) What is the default property for a Text box?

Enabled

Tooltiptext

Text

Passwordchar

Answer : c) Text


2) What is the role or purpose of a variable of type variant?


Answer : A variant is a datatype helps to store any kind of datatype. It can hold an integer, string or an object datatype.


3) What is the purpose of a Form's Name Property? And what is "Me" referred to?


Answer : A name of the form can be used to refer the controls placed in it, from the other form modules or other modules.

"Me" is used to refer the Active form.


4) What is difference between "loading" a form and "showing" a form?


Answer : Loading the form is just loading it into memory and it is not shown to the user.

Answer : Showing the form is actually showing it to the user by using the Show method.


5) How to set a shortcut key for label control? Give an Example.

Answer : A shortcut key can be set for a label control by using the '&' ampersand character. The character which succeeds the '&' character becomes the shortcut key for that label control. Ex: IT&Acumens (Here 'A' is the shortcut key)

6) What do ByVal and ByRef mean and which is the default?

Answer : An argumentlist of a function or subroutine may include the keywords ByVal or ByRef to describe how the arguments are treated by the called procedure.

Answer : ByRef is the default.


7) What does Option Explicit refer to?

Does not require Variable declaration

Require Variable declaration

Variables must be initialized

No need for initialization of variables


Answer : b) Require Variable declaration


8 ) To set the command button for ESC, Which property needs to be changed?


Default

Style

Cancel

Righttoleft


Answer :c) Cancel


9) The Control which do not have any events?


Timer

Frame control

Shape

Progressbar control


Answer : c)Shape


10) What is the primary difference between a function and a subroutine?


Answer : A function will return a variable while a subroutine does not return anything


11) Name some few controls which can be placed in MDI form?


Answer :

i. Statusbar control

ii. Picture box control

iii. Toolbor control

iv. Coolbar control

v. Timer control etc...


12) The Concept of OOP which the VB cannot support?

Polymorphism

Encapsulation

Inheritance


Answer : Inheritance


13) Name the Property used to compress an image in image control?


Answer : "Stretch" property


14) What does Erase command do?


Deletes an object

Initializes a static array

Clears the form


Answer :

b) Initializes a static array


15) How would you center a form on the screen without using the StartUpPosition property using the code?


Answer :


Me.Left = (Screen.Width - Me.Width) / 2

Me.Top = (Screen.Height - Me.Height) / 2


16) What is the use of "For Each....Next" statement? When it is used?


Answer :

The "For Each... Next" loop structure can be used to extract the items present in a collection one by one in a temporary iterator variable of the same datatype present in the collection object.

It is used to manipulate the Form or printer collection objects especially.


17) What is the use of collections in VB? List some advantages. List some important collection objects present in VB.


Answer :


A Collection object is an ordered set of items and used to maintain a collection of objects or other simple datatypes.

Advantages are:

i. Easy insertion and deletion of objects.

ii. Convenient approach.

iii. Easy reference to an object using Key

Examples are:

Forms

Printers


18) When does the Validate event occur?


Answer :

It occurs just before the "Lostfocus" event of an object which supports the Validate event.


19) Which is the correct order of occurrence of events?

Mousedown, Click, Mouseup

Click, Mousedown, Mouseup

Mouseup, Mousedown, Click

Mouseup, Click, Mousedown


Answer : a) Mousedown, Click, Mouseup


20) What is API?


Answer : Application Programming Interface. It is an interface to carry out the low level services of the OS.


21) What should be done to add your own property to a form object?


Answer : The Property Let and Property Put structure has to be used.


22) What is the error in the following statement if the itacumens.bmp exists?

Dim itacumens as Stdpicture

itacumens = Loadpicture("C:\itacumens.bmp")


Answer :

"Invalid use of Property". The second statement must be preceded by the Set statement as Set Zing = Loadpicture("C:\Zing.bmp) since we are initializing an object.


23) Is there a way to break long lines in VB code? If so how?


Answer :

Yes. The long lines can be splitted to multiple lines using the '_' character at the end of the line.

Ex: MsgBox "Unable to display Help Contents. There is no Help associated" & _

"with this project.", vbInformation, Me.Caption


24) How do you prevent the form from unloading after it has entered the Unload event?


Answer :

After it has entered the Unload event make the Cancel argument to True.


25) How do you make the form invisible from the taskbar?


Answer :

By setting its ShowInTaskbar property to False.