Case Study There is a project for “ ABC Café” where the user enters the number of items, selects the coffee type from option buttons, and selects the checkbox for takeout items Q1. Where the user


VB Control Basics

 

The topics that have been presented up until now have followed the "Try It" format for sample programs. The "Try It" format was deliberately sparse and devoid of GUI elements, as the purpose of those topics was to build a foundation in the language itself – variables, basic I/O, built-in functions, control structures, Subs and Functions, file processing, arrays, etc. In other words, the previous topics have been "more BASIC than Visual".

 

Now that the language basics have been covered, the "Try It" format will be retired, and we will concentrate on the more GUI-oriented aspects of VB programming. The GUI aspects of VB programming involves the use of the various controls that are available in the toolbox (there are intrinsic controls, which appear in the toolbox as soon as you open a new VB project, as well as additional "ActiveX" controls that can be added in through the Project -> Components menu).  With controls come properties (a set of variables that describe the appearance, behavior, and other aspects of the control), methods(procedures built into a control that tell the control how to do things), and events (actions that occur in your program). Properties, methods, and events common to most controls are described in the tables below.

Common Properties of Visual Basic Controls

Every object, such as a form or control, has a set of properties that describe it. Although this set isn't identical for all objects, some properties (such as those listed in the table below) are common to most controls. You can see every design-time property for a given control by looking at the Properties window in the IDE (some controls have properties that are available only at run-time – such as the SelStart and SelLength properties of the Textbox).

Property

Description

Appearance

Specifies whether an object's border appears flat or with a 3D look.

Align or Alignment

For controls displaying text, specifies whether text is left, center, or right-aligned. For controls such as a PictureBox or ToolBar, specifies how the control itself is aligned on the form (top, bottom, left, or right).

BackColor

Specifies the background color of the control.

BorderStyle

Generally, specifies whether or not a control has a border. For the Form itself, the type of border can be specified.

Caption or Text

The string of text that is to be displayed in the control.

Enabled

Determines whether or not the control can respond to user-generated events.

Font

For controls displaying text, specifies the font (name, style, size, etc.) to be applied to the displayed text.

ForeColor

Specifies the color of text or graphics to be displayed in the control.

Height

Specifies the height of the control. The default unit is the twip, which is 1/1440 of an inch.

Index

Specifies the element number of a control if the control is a member of a control array.

Left

Specifies the distance between the internal left edge of a control and the left edge of its containter.The default unit is the twip, which is 1/1440 of an inch.

Name

The string value used to refer to the control in code.

Picture

Specifies the graphic to be displayed in the control.

TabIndex

Specifies the tab order of a control within its parent form,

TabStop

Specifies whether or not the user can use the Tab key to give focus to the control.

Tag

A string containing extra data associated with the control.

ToolTipText

Specifies text to be displayed when the mouse is paused over the control.

Top

Specifies the distance between the internal top edge of a control and the top edge of its containter.The default unit is the twip, which is 1/1440 of an inch.

Visible

Specifies whether the control is visible or hidden,

Width

Specifies the width of the control. The default unit is the twip, which is 1/1440 of an inch.

 

Common Methods of Visual Basic Controls

Methods are blocks of code designed into a control that tell the control how to do things, such as move to another location on a form. Just as with properties, not all controls have the same methods, although some common methods do exist, as shown in the table below:

 

Method

Description

Move

Changes an object's position in response to a code request

Drag

Handles the execution of a drag-and-drop operation by the user

SetFocus

Gives focus to the object specified in the method call

ZOrder

Determines the order in which multiple objects appear onscreen

 

Common Events of Visual Basic Controls

Events are what happen in and around your program. For example, when a user clicks a button, many events occur: The mouse button is pressed, the CommandButton in your program is clicked, and then the mouse button is released. These three things correspond to the MouseDown event, the Click event, and the MouseUp event. During this process, the GotFocus event for the CommandButton and the LostFocus event for whichever object previously held the focus also occur.

Again, not all controls have the same events, but some events are shared by many controls. These events occur as a result of some specific user action, such as moving the mouse, pressing a key on the keyboard, or clicking a text box. These types of events are user-initiated events and are what you will write code for most often. Events common to most VB controls are described in the table below.

 

Event

Occurs When ...

Change

The user modifies text in a combo box or text box.

Click

The user clicks the primary mouse button on an object.

DblClick

The user double-clicks the primary mouse button on an object.

DragDrop

The user drags an object to another location.

DragOver

The user drags an object over another control.

GotFocus

An object receives focus.

KeyDown

The user presses a keyboard key while an object has focus.

KeyPress

The user presses and releases a keyboard key while an object has focus.

KeyUp

The user releases a keyboard key while an object has focus.

LostFocus

An object loses focus.

MouseDown

The user presses any mouse button while the mouse pointer is over an object.

MouseMove

The user moves the mouse pointer over an object.

MouseUp

The user releases any mouse button while the mouse pointer is over an object.

 

 

Command Buttons, Text Boxes, and Labels

 

Three of the most basic controls involved in building an interface are command buttonstext boxes, and labels.

 

Command Buttons

The command buttons was the only control that was used in the "Try It" examples. Command buttons are generally used to begin, interrupt, or end a particular process. A user will often use a command button either by clicking it or by tabbing to it and pressing Enter (either of these actions will cause the code behind the command button's Click event to be executed). Other ways of invoking the command button's Click event are (1) set up an "access key" for it (this is shown in the sample program below), (2) set its Default property to True (which allows the user to select that button by pressing Enter regardless of which control currently has the focus), and (3) set its Cancel property to True (which allows the user to select that button by pressing Esc regardless of which control currently has the focus).

 

Labels

A label control is used to display text that a user cannot edit directly. However, you can write code to change the text that is displayed by assigning a string value to the label's Caption property. Common uses of the label control are to display a message to the user and to identify another control (such as a textbox) that does not have its own Caption property.

 

Text Boxes

A textbox control (sometimes referred to as an edit field, edit box, or text entry control) is used to display information entered either by you at design time, by the user at run time, or by an assignment statement in the program code. The displayed text may be accessed by setting or reading the textbox's Text property.

 

Sample Program

Following is the step-by-step process to build a program that adds two numbers together. A simple task, yes, but one that illustrates several concepts related to the controls discussed above. The steps are as follows:

 

1.         Start VB and select "Standard EXE" from the opening dialog.  At this point, VB has started a new project for you and has provided you with one form.

 

2.         Click on the form to make sure it is the active window, then click the Properties window. If the Properties window is not displayed on the screen, you can display it by doing one of the following three things: (1) press F4, (2) click the Properties button on the toolbar (the icon is a hand pointing to a piece of paper), or (3) click View, then Properties Window from the VB menu.

 

            Set the following properties of the form:

 

      Property          Setting

      (Name)            frmAdd

      Caption           Add Program

 

3.         Using the figure below as a guide, place the necessary controls from the toolbox onto the form.  The three basic VB controls are the label, textbox, and command button; these are the controls we will be working with for this program.

 

               

Note on access keys:

 

An access key is a key combination that a user can press (usually the Alt key plus a letter) to invoke an action. Access keys provide a keyboard alternative to using the mouse to perform the same action. For example, most Windows programs that have a File menu will let you open that File menu either by using your mouse to click on the word "File" or by pressing the Alt+F key combination on your keyboard. The "F" in this case would be considered the access key.

 

You can create an access key on any control that has a Caption property (such as a label or a command button) by placing an ampersand (&) to the left of the desired letter in the caption.  On the form, the letter shows up as underlined.

 

For a command button, pressing Alt + the underlined key is the same as clicking the button; it causes the button's "Click" event to fire (more on that shortly).  On a label, provided that the TabIndexes are set properly, the access key causes focus to go to next control that can receive focus (the textbox).  Note on "focus": When a control is "active" – meaning it is either waiting to receive input or is highlighted – that control is said to have the "focus".

 

Note on the TabIndex property

 

Most controls have a TabIndex property. Using the TabIndex property, you can control the sequence of controls that will receive the focus when the user navigates your form via the keyboard. As the user traverses your form by pressing the Tab key, controls will receive focus in the order specified by the TabIndexes. Note that in this sample project, I am calling for the TabIndexes of the nine controls to be in sequence from left to right, top to bottom (we start numbering the TabIndexes with 0, thus the TabIndexes of the controls range from 0 to 8).

 

Certain controls, such as labels, cannot receive focus. However, if you have a label control paired up with a textbox, and you set the TabIndex of the label control to a value one less the TabIndex of the textbox, then you can use an access key on the label's Caption property.  When you do this, you set up a situation such that when the user uses the access key of the label, focus will move to the textbox whose TabIndex has a value one greater than the label's TabIndex.

 

Trick of the trade: Although VB lacks a way to automatically set TabIndexes for all controls in one fell swoop, there is a way to avoid having to enter the exact value of the TabIndex as you go through the controls top to bottom and left to right. What you can do is move from control to control starting right to left, bottom to top, setting the TabIndex to 0 (zero) on each control. As you do this, VB will automatically adjust the TabIndexes of each control. By the time you reach the top leftmost control, your control's TabIndexes will be nicely numbered from 0 to one less than the number of controls on your form.

 

Note on naming conventions for controls:

 

Note that the textbox names are prefixed with "txt", the label with "lbl", and the command buttons with "cmd".  These follow the standard naming conventions for controls. For controls that will not be referred to in code (such as the three descriptive labels), its OK to leave them with the VB default names ("Label1", "Label2", etc.) – but for controls that will be referenced in code, it is highly recommended that they be renamed to conform to the naming conventions.

 

Following is a table listing some commonly used controls and their recommended prefixes:

 

Control type

prefix

Example

Check box

chk

chkReadOnly

Combo box

cbo

cboEnglish

Command button

cmd

cmdExit

Common dialog

dlg

dlgFileOpen

Date picker

dtp

dtpPublished

Directory list box

dir

dirSource

Drive list box

drv

drvTarget

File list box

fil

filSource

Form

frm

frmEntry

Frame

fra

fraLanguage

Gauge

gau

gauStatus

Graph

gph

gphRevenue

Grids

grd

grdPrices

Horizontal scroll bar

hsb

hsbVolume

Image

img

imgIcon

Image combo

imc

imcProduct

ImageList

iml

imlAllIcons

Label

lbl

lblHelpMessage

Line

lin

linVertical

List box

lst

lstPolicyCodes

ListView

lvw

lvwHeadings

Masked Edit

msk

mskPhoneNbr

Menu

mnu

mnuFileOpen

Month view

mvw

mvwPeriod

MS Chart

cht

chtSalesbyRegion

MS Tab

tab

tabFirst

OLE container

ole

oleWorksheet

Option button

opt

optGender

Picture box

pic

picVGA

Picture clip

clp

clpToolbar

ProgressBar

prg

prgLoadFile

RichTextBox

rtb

rtbReport

Shape

shp

shpCircle

Slider

sld

sldScale

StatusBar

sbr

sbrDateTime

SysInfo

sys

sysMonitor

TabStrip

tbs

tbsOptions

Text box

txt

txtLastName

Timer

tmr

tmrAlarm

Toolbar

tbr

tbrActions

TreeView

tvw

tvwOrganization

UpDown

upd

updDirection

Vertical scroll bar

vsb

vsbRate

 

4.         Double-click the Add button.  This causes the code window to open.  Type the following code in the cmdAdd_Clickroutine:

 

Private Sub cmdAdd_Click()

 

    Dim intNum1 As Integer

    Dim intNum2 As Integer

    Dim intSum  As Integer

   

    intNum1 = Val(txtNum1.Text)

    intNum2 = Val(txtNum2.Text)

    intSum = intNum1 + intNum2

    lblSum.Caption = intSum

   

End Sub

 

In this code, a number of things should be pointed out. First, in the statements

 

 intNum1 = Val(txtNum1.Text)

 intNum2 = Val(txtNum2.Text)

 

the syntax txtNum1.Text and txtNum2.Text refer to the Text property of the textboxes txtNum1 and txtNum2 respectively. In general, to refer to a property of a control in code, use "dot" notation, in the format object.property.

 

The Text property of a textbox is considered to be a String data type.  Whatever the user types into a textbox will be stored in its Text property.  The Val function converts a string to a number.  Basically, these statements are saying "convert the contents of the textboxes to numbers and store them in the Integer variables".

 

The statement

 

lblSum.Caption = intSum

 

            does an implicit conversion of intSum from an Integer to a String data type; the string representation is stored in the Caption property of the lblSum label control (the label with the border). This assignment statement causes the sum to be displayed on the form in the lblSum control.

           

Using Default Properties

All controls have a default property, which means that if you omit the ".property" part when referring to a control in code, the default property will be used.  The default property of a textbox is Text, and the default property of a label is Caption.  Therefore, the statements

 

intNum1 = Val(txtNum1.Text)

intNum2 = Val(txtNum2.Text)

           

could have been written as

 

intNum1 = Val(txtNum1)

intNum2 = Val(txtNum2)

 

And the statement

 

lblSum.Caption = intSum

 

could have been written as

 

lblSum = intSum

 

In older versions of VB, it was slightly more efficient to omit the default property; although this is not much of an issue now. Some folks say that omitting the default property detracts from the clarity of the code, although I personally did not agree with that and would omit the default properties when coding. However, I've recently switched from omitting the default properties to explicitly coding them – one reason for this is that in the next version of VB (VB.NET), there will be major syntax changes, one of these is that there will no longer be default properties for objects.

 

5.         We're not done yet, but we can run the program to test the add function.  To run the program, do one of the following three things: (1) click the Run button on the toolbar (looks like a sideways triangle), (2) press F5, or (3) select Run, then Start from the VB menu.  The form should then become the active window.  Type 2 for the first number and 3 for the second, then click the Add button.  The result should be displayed in the designated label, as shown below:

 

                               

               

            You can go back and enter different numbers and click the Add button again.  Also, test the access keys.  Observe what happens when you press Alt+FAlt+S, and Alt+A.

 

If you click the Clear or the Exit button, nothing will happen, because we did not yet write code to respond to the Click events for those buttons (we will fix this shortly).

 

6.         Stop the program.  This can be done by clicking the "X" button on the upper-right-hand corner of the form, by clicking the stop button on the VB toolbar (looks like a black square), or by selecting Run, then End from the VB menu.  Once we finish coding, we will be able to stop the program by clicking the Exit button on our form.

 

7.         We are now back in the "design-time" environment.  Make sure you understand the difference between "design-time" and "run-time".  Double-click the Clear button, and type the following code in the cmdClear_Click event procedure.

 

Private Sub cmdClear_Click()

 

    txtNum1 = ""

    txtNum2 = ""

    lblSum = ""

    txtNum1.SetFocus

 

End Sub

 

            The first three statements in this procedure use the default properties of the textboxes and the sum label to clear the text out of their Text and Caption properties, respectively. This is done by assigning the "empty string" to them – the "empty string" ("") is simply two quotes next to each other with nothing in between.. Visually, the text in these controls will disappear when these assignment statements are made.

 

            The last statement, txtNum1.SetFocus causes the cursor to be positioned on the txtNum1 textbox.  "SetFocus" is a method of the textbox.  Methods of objects generally perform some action on the object. SetFocus causes the control  in question to be the "active" control.  The general format for invoking a method on an object is object.method.

 

8.         Double-click the Exit button to open the code window for the cmdExit_Click event.  Simply type the word End after the procedure header:

 

Private Sub cmdExit_Click()

 

    End

 

End Sub

 

9.         Run the program again.  The Clear and Exit buttons should now work. When you are done testing the program, exit it to return to the design-time environment.

At this point, the basic functionality of the program is complete, although there are a handful of enhancements that can be made.  These enhancements are described below.  As each enhancement is discussed, add it to your program and test it.

 

One enhancement is to highlight the text in a textbox when that textbox receives focus.  To do this, code the GotFocus event for that textbox:

 

Private Sub txtNum1_GotFocus()

 

                                     txtNum1.SelStart = 0

                 txtNum1.SelLength = Len(txtNum1.Text)

 

End Sub

 

The SelStart and SelLength properties are used to highlight all or partial text in a textbox. These properties are only available through code; they are not available the Properties window. The SelStart property specifies on which character position of the text the highlighting should begin (it is zero-based, so 0 means the first character). TheSelLength property specifies how many characters of the text should be highlighted. In the example, we are using the Len function on the text in the textbox to set the SelLength property to the total number of characters contained in the text. Thus, the two statements coded in this event have the effect of highlighting the current text in the textbox.

 

To "factor out" an object (like the "txtNum1" textbox) in a series of statements, you can use a With/End With block (results in more efficient code because VB does not have to repeatedly resolve the object reference when compiling/interpreting).  The following code is equivalent to the above:

 

Private Sub txtNum1_GotFocus()

 

    With txtNum1

        .SelStart = 0

        .SelLength = Len(.Text)

    End With

 

End Sub

 

The GotFocus event for txtNum2 should be coded in the same manner:

 

Private Sub txtNum2_GotFocus()

 

    With txtNum2

        .SelStart = 0

        .SelLength = Len(.Text)

    End With

 

End Sub

 

A second enhancement would be to weed out non-numeric characters as the user types in the textbox.  To do this, you would code a KeyPress event for that textbox, as shown below:

 

Private Sub txtNum1_KeyPress(KeyAscii As Integer)

   

    If KeyAscii < 32 _

    Or InStr("0123456789", Chr$(KeyAscii)) > 0 Then

        ' OK - do nothing

    Else

        KeyAscii = 0

    End If

   

End Sub

 

In the code above, the first thing to note is that VB automatically passes an integer parameter called KeyAscii to the KeyPress event. This integer contains the ASCII code corresponding to the key that the user pressed. The logic first tests to see if the ASCII key code is less than 32 – if it is, that's OK because ASCII characters 31 and below are "control" keys, such as the backspace and arrow keys, and we don't want to restrict the user from entering those keys. The logic also uses the InStr function to see if the character equivalent of the ASCII code is contained within the set of numeric digits – if it is, that's OK, we want the user to enter only digits. If either of those tests fail, we reset the KeyAscii variable to 0, which has the effect of nullifying the user's keystroke – for example, if the user typed the letter "A", it would appear to them that that key is "dead" – it would not appear in the textbox.

 

The KeyPress event for txtNum2 should be coded in the same manner:

 

Private Sub txtNum2_KeyPress(KeyAscii As Integer)

   

    If KeyAscii < 32 _

    Or InStr("0123456789", Chr$(KeyAscii)) > 0 Then

        ' OK - do nothing

    Else

        KeyAscii = 0

    End If

   

End Sub

 

If you want to limit the number of digits the user types into a textbox, you can set the MaxLength property of the textbox.  By default, the MaxLength property of  a textbox is 0, meaning there is no limit to how many characters the user can type.  Set the MaxLength property of txtNum1 and txtNum2 each to 4.

 

The final enhancement discussed here is the implementation of an "auto-tab" feature.  This is a feature where, when the user types in the maximum number of characters in a control, they are automatically tabbed to the next available control.  Textboxes do not have an auto-tab property, but one can be implemented by setting the MaxLength property and then coding the Change event for that textbox.  For example, you code the Change event for txtNum1 and txtNum2 as follows:

 

Private Sub txtNum1_Change()

    With txtNum1

        If Len(.Text) = .MaxLength Then

            txtNum2.SetFocus

        End If

    End With

End Sub

 

Private Sub txtNum2_Change()

    With txtNum2

        If Len(.Text) = .MaxLength Then

            cmdAdd.SetFocus

        End If

    End With

End Sub

 

Download the VB project code for the example above here.

 

The subsequent topics in this chapter are a series of programming exercises, where you can combine the language basics you have learned in the previous chapters along with the GUI concepts presented in this topic to solve some simple and some not-so-simple programming tasks.

The InputBox and MsgBox functions

InputBox and MsgBox are two useful functions. Each opens a dialog window, which closes when the user responds. The InputBox is used to get input from the user and MsgBox is used for output. These our illustrated in this simple message program. The following is its listing:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim strName As String

strName = InputBox("What is your name?")

MsgBox("Thanks, " & strName & ". I have been waiting weeks for someone to do that.")

End Sub

In this example, the InputBox function has one argument, a string that is used to promptthe user. The function returns whatever the user enters. (If the user clicks on the cancelbutton, a string of length zero is returned).

The MsgBox function also has one argument in this example. It is a string to be displayed in the message box.

The InputBox function requires at least one argument (the prompt), but it has 4 optional arguments. The optional arguments are a title (string), a default input value (string), and X and Y coordinates (numeric) that determine the position of the input window on the screen.

For example, this program:

Dim strUserIn As String

strUserIn = InputBox("This is the prompt", "This is the title", "This is the default input", 1, 1)

produces this InputBox in the uppler left corner (1, 1) of the screen:

Case Study There is a project for “ ABC Café” where the user enters the number of items, selects the coffee type from option buttons, and selects the checkbox for takeout items Q1. Where the user 1

Similarly, the MsgBox function requires one argument, a string with the message, but has 2 optional arguments, a numeric code that indicates which buttons to display on the message box and a string title for the message box.

The button code is most interesting. Using it, you can put OKCancelRetry, and other buttons on the message box, The following are some of the allowable button code values:

Code

Buttons displayed

OK (the default)

OK and Cancel

Abort, Retry, and Ignore

Yes, No, and Cancel

Yes and No

Retry and Cancel

You can experiment with these and check the online help for other MsgBox options.

For example, this program:

Dim intButton As Integer

intButton = MsgBox("This is the message", 3, "This is the title")

produces this InputBox:

Case Study There is a project for “ ABC Café” where the user enters the number of items, selects the coffee type from option buttons, and selects the checkbox for takeout items Q1. Where the user 2

If there are multiple buttons on a message box, the programmer might also want to know which one the user clicked. The following table shows the values the MsgBox function can return:

The user clicked

Value returned

OK

Cancel

Abort

Retry

Ignore

Yes

No

Finally, we should note that the Show method of the MessageBox class may be used as an alternative to the MsgBox function. For example, the following statement displays a MessageBox with a greeting:

MessageBox.Show("Hiya kids, Hiya! Hiya!")

Like the MsgBox function, the Show method returns a value that can be tested later in the program to see which button the user had clicked on, for example:

Dim bob As Integer

bob = MessageBox.Show("Hiya kids, Hiya! Hiya!")

What is the difference between message box and input box in Visual basic?

MESSAGE BOX

A message box is non-interactive. It just simply displays an output message for the user to read; and, that's it. When you click button [OK]...the message box immediately closes down/disappears.

MsgBox("Hello, world!")

INPUT BOX

An Input box is interactive; it usually will ask the user to type in some value such as either a number/or, text. This time, whenever the user clicks on the button [OK]; the input dialog box disappears; however, the number/text value which the user went and typed in will, normally, get stored inside of a program memory box variable name; so that the program can get to do something with this value, later on.

num=InputBox("Enter a number: ","PROGRAM: Find square of number")

MsgBox("The square of your number is: " & num*num)

Also, the MsgBox displays a dialog box with a message displayed on a label and command button to choose one of the few possible actions. But, in an InputBox, its displays a dialog box with a message displayed on a label, a textbox to enter data and command button to accept or ignore the data entered.

What is common dialog box in visual basic control?

The common dialog box in visual basic is an insertable control that allows users to display a number of common dialog boxes in their program. These include Open and Save As file dialog boxes; the Find and Replace editing dialog boxes; the Print , Print Setup , Print Property Sheet , and (MORE)

What is the difference between image control and picture box In Visual Basic Language?

what is the difference between list box and combo box in visual basic 6.0 picture box: 1) it act as container control 2) use of memory to store the picture 3) editing of picture is possible in picture box 4) having auto size property 5) not having stretch property Image Box:  (MORE)

What is the difference between Visual Basic and Visual Basic.NET?

VB.NET is just Visual Basic implemented onto Microsoft's .NET Framework, both being Microsoft languages. While Visual Basic is part of Visual Studio, VB.NET is also part of the Visual Studio.NET release. Development of Visual Basic stopped at version 6, and VB.NET simultaneously was born at version  (MORE)

What is the difference between block box and white box testing?

White box testing or unit testing : To do whitebox testing, knowledge of internal logic code is required. It ismostly done by developers. Black box t esting: The functionality of anapplication is tested; logic code is not required. This testing isdone by testers. Block box or system testin (MORE)

What is the difference between goal box and penalty box in soccer?

The goal box is where you kick the ball past the goalie to score agoal for your team. The penalty box in soccer occurs around the18yard area and is just before the goal line. It can result in apenalty kick if the ball goes here.

What is the difference between a procedure and a function in Visual Basic?

Although these two terms refer to similar processes there is a technical difference. A procedure is a snippit of code that is a specific list on instructions that a program may execute once or twice. Basically a procedure will only run once everytime it's action is called. A function is kind of like (MORE)

What is the difference between arrays and collection in visual basic?

Arrray has a fixed size i.e it's size cannot be increased or decreased without reconstruction it, but this facility is only provided by some languages not all.. Collection on the other hand does not need to be reconstructed, it increases or decreases its size if we add or remove items from it..

What is the difference between Qbasic and visual basic?

QBASIC is not a visual language, although it can be used to create very crude visual programs (much like a BIOS screen in appearence). In contrast, Visual Basic can be used to create Windows-Based programs using the appropriate GUI and as such far more user friendly.. Personally, I would use PASCAL (MORE)

Difference between picture box and image box?

Main Difference: The Image control is a lightweight control that has no device context (or hDC) or it's own. The Picturebox does have a device context and hDC and is a true "window" from the point of view of the Windows operating system (and can directly use "hWnd" parameter API calls). Du (MORE)

What is the difference between combo box and list box?

A list box displays a list from which the user may make a selection. The default behaviour is to permit a single selection, but multiple selections are also permitted by changing the SelectionMode accordingly. A combo box combines a list box with a text box, but the list is limited to single select (MORE)

What is the difference between visual basic and visual c?

The programming language: Visual Basic is a BASIC-like (or BASIC-derived) language, Visual C is... well C.

What is the difference between visual studio and visual basic?

I believe visual studio is the user interface, and it not only supports visual basic but also visual c++, c#, web development etc. Visual basic, on the other hand, is a programming language.

What is the difference between message box and input box give example for each of them?

we can use msgbox for display the message and getting input from user like vbyes/no method.. but inputbox only for input.. and for msgbox we can't set the x,y margin.. but in the input box we can set.. we can use inputbox as a variable value taker..............

What is the difference between image box and picture box in visual basic 6.0?

picture box: 1) it act as container control 2) use of memory to store the picture 3) editing of picture is possible in picture box 4) having auto size property 5) not having stretch property Image Box: 1) it is not act as container control 2) not use of memory to store the pict (MORE)

What is the difference between class and object in visual basic?

A class defines the properties and methods that several objects share. Objects on the other hand take up space in memory and have physical addresses where the memory can be found. For every class there may be multiple objects allocated, but all of those objects have the structure and methods determi (MORE)

What is difference between msgbox and input box?

The inputbox used for input any value/data from user in run time. But msgbox is use for showing any message/information to user, that is write by user in design time (in code)

Visual basic what is the different between labels and text boxes?

When creating labels, you can only create labels in your documents.With text boxes, you can create the box and text can immediatelyfollow the text box.

What is the difference between visual basic to Microsoft access?

n reply to your 4 questions: a) Yes: VB is the same as VBA when it comes to modules, procedures, variables, loops, branches, operators, and many functions. b) As above. c) There is some similarity between VB forms/controls and Access forms/controls, but they are different in crucial way (MORE)

What are the function of different objects in visual basic tool box?

Given the fact there are around 50 default controls provided within the toolbox of visual studio, each with a highly in depth range of properties, events, methods and parameters you should probably focus your question on which individual tool you wish to know about. It is probably possible to write (MORE)

Differences between visual basic and Microsoft visual basic?

There is no difference. Microsoft Visual Basic and Visual Basic are the same thing. Visual Basic is a language that was developed by Microsoft. There is however a difference between Visual Basic and Visual Basic .NET (Now known as just Visual Basic and VB.Net). VB.Net is basically Visual Basic, t (MORE)

Difference between combo box and list box in visual basic and how to impact to make website by using these control and dtp?

LISTBOX CONTROL . COMBOX CONTROL . A LISTBOX CONTROL displays a list of items from which theuser can select one or more. If the number of items exceeds the number that can be displayed, a scroll bar is automatically added to the List Box control. a list box is appropriatewhen you want to limit inp (MORE)

How do you empty a text box in visual basic?

Assuming you have text box called txtUserName To clear the contents of the text box, use double speech marks e.g. txtUserName.text = ""

What is Difference between visual basics and visual studio?

\nVisual Basic is more like a scripting language used to get additional functionality from Microsoft applications such as its Office Suite. On the other hand Visual Studio is a developement environment used to create full fledge Microsoft Applications. These applications when compiled and deployed c (MORE)

How do I change a picturebox depending on a combo box using visual basic 2008?

First, you have to determine how many pictures you want to have as a result. Take all those pictures and put them in picture boxes(however many pictures you want as a result, These do not have to be visible, or even in the same form, but if they aren't in the same form, use code 2). In picturebox2 y (MORE)

Difference between messege box and input box?

we can use msgbox for display the message and getting input from user like vbyes/no method.. but inputbox only for input.. and for msgbox we can't set the x,y margin.. but in the input box we can set..

Difference between pribnow box and hogness box?

A SH=hort nucleotid esequence in the promoter 25 to 35 bp upstream to the transcription initiation site of eukaryotic genes to which polymerase binds is called TATA BOX. IT IS CALLED AS PRIBNO BOX IN CASE OF PROKARYOTES and called as HOGNESS BOX in case of EUKARYOTES.. It has conserved squence of  (MORE)

What is the difference between PHP and Visual Basic?

The two languages have hardly any similarities. PHP is based on Perl, which is based on C and C++. Resemblance to the syntax of other C languages is strong, with the primary differences being the dot . for concatenation, and the double-colon :: and hyphen-arrow -> borrowed from C++ for static and in (MORE)

What are the differences between checkbox and optionbutton in visual basic 6?

CheckBox: A box which can be checked or not checked. OptionButton: Every OptionButton is part of a group. Only one option button in a group can be checked.

What is the difference between rich textbox and textbox in visual basic?

TextBox can display text without or less formatting it can display all of its Text in same formatiing. Like Bold, Italic Uderline or combination. You can give it fore color and also change font. That's it! RichTextBox facilitatets us to format different parts of text differently. Like 1 Area of te (MORE)

What is the Difference between combo box and list box in visual basic?

Combo box has an arrow down button or dropped down while list boxis you just select on the list. combo box: 1. We can select ony one option from list. 2. We can add ,edit,select info. at run time. 3. We have only drop down facility. 4. We can't use checkbox within combobox. 5. Occupies less space bu (MORE)

What is the Difference between text box and input box?

In a text box user can enter the text that text can be edited and changed. In Input box ,the data can be accepted which is entered by the user through the text box. Text box have some properties. Input box have not specific properties. Three method which can displayed in the text box. 1) At Desig (MORE)

What were differences between boxing in the 1920s and boxing now?

This is a topic that could be covered in a very large book, especially if we were to delve into the culture of the time, the safety (or lack thereof) and the money differences ... But let me summarize as best as I can, purely from a strategic position... Boxing in the 1920s made an enormous leap for (MORE)

What are the differences between boxing and sailing?

boxing is a sport you play with your fists. sailing is a sport you do with a boat on water, ugg. People. C'mon! You could be a little smarter.

How do you use message boxes in visual basic?

Example: MsgBox("This is an example!", MsgBoxStyle.Information, "Example") or: MsgBox("This is an example!", MsgBoxStyle.Exclamation, "Example") or: MsgBox("This is an example!", MsgBoxStyle.Critical, "Example") you can choose between one of these three styles. just add one of these in the li (MORE)

What is Difference between C and Visual Basic?

They're two entirely different programming languages, so it's rather like asking what's the difference between French and English (possibly more like asking what's the difference between German and English). One difference is that Visual Basic is a product of a specific company - Microsoft - wh (MORE)

What is a message box in visual basic?

A message box is a predefined function which displays a box containing text, a title, a series of buttons and a small indicative picture to the user informing them of the basic nature of the message (E.g A Critical Exception would have a large red circle with a cross in it). It will return an intege (MORE)

What is the difference between Text and Name in Visual Basic programming?

in every control(textbox, button, form...) there is Name property and Text property. Name property changes the Name of a control(example Form1 to frmAddBooks, TextBox1 to txtName etc... ), Text on the other hand changes only the "caption" of a certain control, in other words, the text to be display (MORE)

What is dialog box in visual basic?

A form which has the focus, eg a msgbox box is a dialog because you can't do anything else until you close it, Open save font and colordialogs are good examples of dialogs too

What is the difference between Visual Basic and Basic?

Well it is to do with the 'visual' part of the software. Basic was originaly created for bigger computer. However, visual basic inclludes a simple interface where you can draw then code.

What is the meaning of tool box in visual basic?

The toolbox is used to drag controls onto a form to do various functions. Such as a button which could do something when you click it.

How can you empty text box at run time in visual basic?

Let's assume youre text box is called: Text1; then, to clear it at RUN time you can use the following code... Text1.Text = ""

What is the difference between wrestling and boxing?

boxing-In this you can only hit your opponent by punchs wrestling-in this you can do everything you want to do with your opponent apart from breaking his neck in a comment to the last answer, you can do everything to your opponent apart from breaking the neck in Pro Wrestling only. In Amateur wre (MORE)

What is the difference between image control and picture box in visual basic 6.0?

Image control is similar to the picture box control, in that it can display images, but it can support only a few features if picture box control.

What is combo box in Visual Basic?

A combo box is a list of multiple values a user can select.Sometimes we refer to them as dropdown lists. When you click on ita list of value pops down and you can choose an option. They arevery commonly seen on computers. To create them you use the ComboBox control in Visual BASIC.

What is the difference between tool box and property window in visual basic?

a tool box has controls that can be clicked and drugged to objects e.g a form for use the controls are used to create a GUI in visual basic while a property windows contains all the textual description of the form and its controls in visual basic.

What is the difference between gear box cover and gear box?

The actual gear box is the area off gears.....and the gear box cover .....covers that area

What is the difference between caption and name property in Visual Basic?

The name property is the user-defined name through which you referto a specific control. It works in conjunction with the indexproperty when working with an array of objects of the same type.The name of an object cannot be changed at runtime; it is adesign-time property. The caption is an optional p (MORE)

How do you find the product of all the items in a list box using visual basic?

Don't use a list box for this. The purpose of a list box is topresent a list of items from which a user can make a selection.That's clearly not what you are trying to do. Use an array instead(you can always construct a list box from an array if required): Dim values As Integer() = {5, 3, 6, 4, 2} Di (MORE)

What is the difference between cardboard boxes and corrugated boxes?

Cardboard boxes are industrially prefabricated boxes,primarily used for packaging goods and materials. Corrugated boxes are also called as Carton in general terms , usedfor packing all types of products and can be reused and recycled ,It is made out of paper and can handle any type of productpack (MORE)

What are the Similarities between image box and picture box in visual basic 6.0?

Image and picture box are used to uploadâ images from the computerfiles. *These both supports all the graphical properties like clipcontrol,scale,e.t.c.

What is the difference between Inputbox and MessageBox in VB?

 Something Different (Study Materials,New Think)    10:42

InputBox(): The InputBox() function is used to take the input from the user at run time.


The general Syntex is:  InputBox(prompt,title,default,xpos, ypos, helpfile, context)

Arguments:

  • Prompt: The message in the dialog box.

  • Title: The title-bar of the dialog box.

  • Default: String to be displayed in the text box on loading.

  • Xpos: The distance from the left side of the screen to the left side of the dialog.

  • Ypos: The distance from the top of the screen to the top of the dialog box.

  • Helpfile: The Help file to use if the user clicks the Help button on the dialog box.

  • Context: The context number to use within the Help file specified in helpfile.

Case Study There is a project for “ ABC Café” where the user enters the number of items, selects the coffee type from option buttons, and selects the checkbox for takeout items Q1. Where the user 3



MsgBox():Displays a dialog box containing a message, buttons, and optional icon to the user. The action taken by the user is returned by the function as an integer value.

Syntax: MsgBox(prompt, buttons, title, helpfile, context)

Arguments:


  • Prompt: The text of the message to display in the message box dialog.

  • Buttons: The sum of the Button, Icon, Default Button, and Modality constant values.

  • Title: The title displayed in the Title-bar of the message box dialog.

  • Helpfile: An expression specifying the name of the help file to provide help functionality for the dialog.

  • Context: An expression specifying a context ID within helpfile.