Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Visual Basic Expert

CONTROL ARRAY

The control array is a group of similar objects with similar name. Adding controls with control arrays uses less resource than simply adding the multiple controls of similar type to a form at the design time. The Control arrays are also helpful if you want some controls to share the code. For illustration, if 3option buttons are formed as a control array, the similar code is executed in spite of which the button was clicked.

If you desire to create a new instance of a control at the run time, that control should be a member of the control array. Through a control array, each new element inherits the common event process of the array.

By using the control array mechanism, each and every new control inherits the common event procedures previously written for the array. For illustration, if your form has some text boxes that each receives a date value, the control array can be put up so that all of the text boxes share similar validation code.

For illustration you can have some Text Boxes with similar name and differentiate them with the help of a subscript. We will observe how to create a control array. We are going to create an array of the textboxes. Follow the steps below to create a control array of textbox.

1. Build a VB project.

2. Click the command button and attach it on the form.

3. Drag the Text Box control and set it on the form.

4. Copy the Text Box control.

5. Paste the copied Text Box control on the form.

6. The following message would be exhibited.

7. You previously have a control named Text1'. Do you desire to create a control array?

8. Choose yes and the Text Box control would be pasted on the form.

9. Now Paste as many times as you wish for. For illustration to create a control array with 3 elements paste the control 2 times.

10. Handle the click event, for the command button.

11. Comprise the code below in the event handler.

Private Sub Command1_Click()

Dim an As Integer

For an = 0 To 2

Text1(an).Text = Val(Text1(an).Text) + 5

Next an

End Sub

The Val function changes the content of Text1 to numeric. The subscript, an, is used to access the different text boxes; an (0) would refer to the first text box, an (1) would refer to the second text box and an(2) would refer to the third text box. 

Visual Basic, Programming

  • Category:- Visual Basic
  • Reference No.:- M9510941

Have any Question?


Related Questions in Visual Basic

Assignment virtual storeuse the concepts and scenario from

Assignment: Virtual Store Use the concepts and scenario from Assignment 1 to help "Your" Virtual Business to increase the functionality of its online shopping cart. When a customer checks out, the shopping cart must stor ...

Assignment frans virtual fruit standfrans virtual fruit

Assignment: Fran's Virtual Fruit Stand Fran's Virtual Fruit Stand is an online store that sells several types of dried fruit. Based on the needs of Fran's Virtual Fruit stand, you must design a flowchart using Visual Log ...

Please show how to do the belowvisual basic net application

Please show how to do the below: Visual Basic .NET Application - Coding Exercise 1 (Exercise 13, Zak, 2016, p. 347) For this coding exercise, write the Visual Basic code for a pretest loop that uses an Integer variable n ...

Pitch amp game design documentthe assignment is about

Pitch & Game Design Document The assignment is about educational driver for teenagers Assignment Brief: In groups you will: - present a pitch and produce a one sheet - provide a demonstration of your game - produce a hig ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As