VB 21-30

Embed Size (px)

Citation preview

  • 7/28/2019 VB 21-30

    1/3

    Q21. What do you mean by control in VB6.

    In Visual Basic, the tool you use to create objects on a Visual Basic form. Controls are selected from the Toolboxand then used to draw objects on the form with the mouse pointer. It's key to realize that the control is just thetool used to create GUI objects, not the object itself.

    Q22. Explain deference between a data control and data-bound control.

    Ans:

    Using data control is a two-step process. First you place a data control on a form and set the properties to link itto a database file and table Data control generally links one form with one table. Prefix of data control is dat.You create the controls, such as labelsand text boxes, to display the actual data. Each control is a bound toparticular field in the table. In this example the label is called a data bound control and automatically displaysthe contents of bound field when the project runs.

    If you want to have data-bound controls on second form, you must place a data control on that form. For data-bound control prefix depends upon the control which you are using. Data control to work you need to set someproperties to connect with database like connect property, database name property, record source property. Todisplay data on the data-bound control that you are using like labels or textboxes. You need set its data sourceproperty and data field name which is column name form the table.

    Q23. What is text box control? What are the basic properties of a text box control?

    1) TextBox controls offer a natural way for users to enter a value in our program. For this reason, theytend to be the most frequently used controls in the majority of Windows applications.

    Property/ Method Description

    Properties

    Enabled specifies whether user can interact with this control or not

    Index Specifies the control array index

    LockedIf this control is set to True user can use it else if this control is set to false the

    control cannot be used

    MaxLengthSpecifies the maximum number of characters to be input. Default value is set to0 that means user can input any number of characters

    MousePointer Using this we can set the shape of the mouse pointer when over a TextBox

    Multiline By setting this property to True user can have more than one line in the TextBox

    PasswordChar This is to specify mask character to be displayed in the TextBox

    ScrollBarsThis to set either the vertical scrollbars or horizontal scrollbars to make appear inthe TextBox. User can also set it to both vertical and horizontal. This property isused with the Multiline property.

    Text Specifies the text to be displayed in the TextBox at runtime

    ToolTipIndex This is used to display what text is displayed or in the control

    Visible By setting this user can make the Textbox control visible or invisible at runtime

    Method

    SetFocus Transfers focus to the TextBox

    Event procedures

    Change Action happens when the TextBox changes

    Click Action happens when the TextBox is clicked

    GotFocus Action happens when the TextBox receives the active focus

    LostFocus Action happens when the TextBox loses it focus

    KeyDown Called when a key is pressed while the TextBox has the focus

    KeyUp Called when a key is released while the TextBox has the focus

    Q24. Why VB is called Event-Driven programming language?

  • 7/28/2019 VB 21-30

    2/3

    In traditional or procedural application, the application itself determines which portion of code is to be executedand in what sequence. Generally execution starts with the 1st line of code and follow the coding sequencedefine in the application. Whereas application written in VB are Event-Driven. In an event-driven applicationthe code doesnt follow a predetermined path rather it execute different code sections in response to events.Event can be triggered by users action, by message from system, other applications or even from theapplication itself. The sequences of these events determine the order in which the code execute and associatedwith the objects of application. They either act on an object or are triggered by an object to control the flow ofexecution when it is running. That is why VB called Event-Driven programming language.

    Q25. Why is a form considered a container control?

    An application's object is programmatically referred to as a parent when it can host, hold, or carry otherobjects. For this reason, such a window is also referred to as a container. So a form can be consider as acontainer because it can host many other controls

    The most common and the most widely used container is the form.

    As mentioned already, there are two categories of controls: parents and children:

    Parent: A parent control "carries", "holds", or hosts the controls positioned on it. When a parent is

    created, made active, or made visible, it gives existence and visibility to its controls. When a parent

    gets hidden, it also hides its controls

    Child: A window is referred to as child when its existence, its visibility, and its availability depend on

    another window referred to as its parent. Except for the forms, all of the Windows controls you will usein your applications are child controls and they must be parented by another control.

    Q26. Differentiate between MDI and SDI.i) SDI can load only 1 document at a time, however it can have multiple views in the same window using splitterwindows property.Example is a notepad in windows.

    An MDI application has multiple child windows, each of which corresponds to an individual document. MicrosoftWord is a good example of an MDI application.ii) With SDI option all the IDE windows are free to be moved anywhere on screen as long as Visual Basic is in

    the current application.With the MDI option all the IDE windows are contained within a single resizable parent window.

    Q27. What is a purpose of image control and how can it be created ?

    Ans.

    An image control holds a picture. You can set an image picture property to file with an extension of .bmp,.GIF,.JPEG etc. First place the image control on a form and then select its picture property in the properties window.Click on the properties button to display load picture dialog box where you can select a filename. You can useany picture file ( with the property format ) that you have available. Set the Stretch property of image control totrue to make the picture enlarge to filled the control .You can set the visible property to false to make theimage disappear. The letter prefix for naming an image is img.

    For Example, to make an image invisible at run time , use this code statement:

    imgLogo . Visible = False

    Q28. Find the differences between two dates using function.

    We use datediff() function to find out the defference between two dates.

    Ex: datediff(d,12/09/10,12/12/10)

    We evaluate to 3 days.

  • 7/28/2019 VB 21-30

    3/3

    Q29. What is a listBox and ComboBox?

    Ans ListBox :

    ListBox present a list of choices that are displayed vertically in single column, if number of items exist the valuecan be displayed scrollbar automatically appear on control. ListBox have list property contain list or item todisplay. To add the item at design time, click on list property & add item, press ctrl + enter after adding eachitem. To add item at runtime to AddItem method is used.

    Syntax is as following :

    object.AddItem item, index

    The item argument string that represents text to add to the list . The index argument is an integer thanindicated when in list to add the new item.

    ComboBox :

    A combobox control is combination of textbox and listbox. This control enables user to select either by typing inthe text into combobox or by selecting items from the list.

    The combobox controls has three different style that can be set .

    a) Drop down combo (style 0)

    b) Simple combo (style 1)

    c) Drop down list (style 2)

    Q30. Name and describe the three styles of combobox.

    Ans Combobox:

    A combobox control is combination of textbox and listbox. This control enables user to select either by typing inthe text into combobox or by selecting items from the list. The combobox controls has three different style thatcan be set .

    a) Drop down combo (style 0)

    b) Simple combo (style 1)

    c) Drop down list (style 2)

    a)Drop down combo :

    It first appears as only an editable area with down arrow button to drop down list portion with this style. We caneither type text into text portion which is an editable area or select a value from drop down list. The list portionstatus hidden until the user clicks down arrow button to drop down list portion.

    b)Simple combo:

    This style looks like listbox setting directory underneath a textbox. The listbox , which is below textbox which isalways visible showing an item present in it. Scrollbar display decides the list if there are to many item todisplay in listbox area. So important thing is , list is always present below textbox. Hence there no downwardarrow button which are used to open a list, in case of drop down combo.

    c)Drop down list Combo:

    The drop down list combobox terms combobox into drop down listbox at run time , the control looks like dropdown combobox. The user click on down arrow view list. Main difference between drop down combo & dropdown list combo are editable are in the drop down list disable i.e. means user can only select from item listed inportion of listbox of the combobox and he cant type and item in the next or edit area of the combobox.