Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Visual Basic Expert

Mostly time, you just desire to assign a single value to a variable you have declared. A variable having a single value is a scalar variable. At other times, this is convenient to assign more than one associated value to a single variable. Then you can create a variable which can have a series of values. It is called an array variable. Array variables & scalar variables are declared in the same way, apart from that the declaration of an array variable employee parentheses ( ) following the variable name. In the following instance, a single-dimension array having 11 elements is declared:

Dim A(10)

Although the number illustrated in the parentheses is ten, in VBScript all arrays are counted from base 0, so that actually this array contains 11 elements. In such an array, the number of array elements is always the number illustrated in parentheses plus one. This kind of array is known as fixed-size array.

You assign data to each of the elements of the array via an index into the array. Starting at zero and ending at 10, data will be assigned to the elements of an array given as:

A(0) = 256

A(1) = 324

A(2) = 100

. . .

A(10) = 55

Likewise, the data can be retrieved from any element via an index in the specific array element you desire. For illustration:

. . .

SomeVariable = A(8)

. . .

Arrays are not restricted to a single dimension. You can have as several as 60 dimensions, although mostly people cannot comprehend more than three or four dimensions. Multiple dimensions are declared through separating an array's size numbers in the parentheses along commas. In the following instance, the MyTable variable is two-dimensional array having 6 rows and 11 columns:

Dim MyTable(5, 10)

In a two-dimensional array, always the first number is of rows; the second number is of columns.

You can also declare an array whose size alter whereas your script is running. It is called a dynamic array. Initially the array is declared in a process either using the Dim statement or the ReDim statement. Though, for a dynamic array, no size or number of dimensions is placed inside the parentheses.

For instance: Dim MyArray()

ReDim AnotherArray()

To employ a dynamic array, you have to subsequently use ReDim to find out the number of dimensions and the size of each dimension. In the following instance, ReDim sets the initial size of the dynamic array to 25. A subsequent ReDim statement resizes array to 30, however uses the Preserve keyword to preserve the contents of the array as the resizing takes place.

ReDim MyArray(25)

. . .

ReDim Preserve MyArray(30)

There is no limitation to the number of times you can resize dynamic array, although you should know that if you make an array smaller than it was, you lose the data in the removed elements.

Visual Basic, Programming

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

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 ...

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 ...

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 ...

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 ...

  • 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