Current location - Training Enrollment Network - Mathematics courses - Definition and assignment of VBA array
Definition and assignment of VBA array
Can be directly defined, but not directly assigned, please refer to the following code:

1 and Dim arr( 1 to 3) in the form of strings.

So defined, but you can't directly assign values to arrays.

If you want to assign a value to an array directly, you need to do the following:

Dim arr () as a variable

arr=Array("a "," b "," c ")

2. Dim A as a variant

A = array (10,20,30)

B = A(2)

The array function returns a variant and cannot be used by assigning values to array variables.

Extended data:

Common built-in functions of VBA:

dialog box

Input box

Rounding function: fix rounding to 0, Int rounds down, and round rounds.

Rnd: Returns a single-precision random number in the range of 0- 1

String function:

Filter: filters an array of one-dimensional strings.

InStr([Start,]& lt; str 1 & gt; , & ltStr2 & gt[, Compare]) and InStrRev: Find substring.

Len: string length

Join: Join all substrings in a one-dimensional array.

Left, right and center: Intercept substring.

Space (numerical value): generates a space string.

Ucase, Lcase: case conversion function

Ltrim, Rtrim, trim: Delete leading and trailing spaces.

replace

Split: Split a string into a one-dimensional array.

StrComp: string comparison

StrConv: string conversion

String(number, character): specifies how many times the character is repeated.

Baidu Encyclopedia -VBA (Visual Basic Macro Language)