[VB learning] 3: Data type and control structure

xiaoxiao2021-03-06  44

An array of any data type requires 20 bytes of memory space, plus 4 bytes of each array dimension, plus the space occupied by the data itself. The memory space occupied by the data can be calculated by multiplying the size of each element by the number of data metades. For example, data in a one-dimensional array composed of four 2 bytes of Integer data is 8 bytes. These 8 bytes plus additional 24 bytes such that the total memory space required for this array is 32 bytes.

Variables and constants: must begin with letters or Chinese characters, consisting of letters, Chinese characters, numbers or underscores, length ≤ 255 characters.

Dellar string: DIM Stra As String * 10, indicating that up to 10 characters, if it is less than 10, then right fill; if more than 10, the excess part is intercepted.

Unschedule: DIM Stra As String, up to 2MB of characters can be stored.

&: The operand on both sides of the connectors regardless of the characteristic or numeric type, the system first converts the operand into characters and then connects.

: The number of operands on both sides is a character type; if it is a numeric type, the arithmetic addition operation is performed; if one is a numeric character pattern, a numeric type, the digital character is automatically converted to a value, then arithmetic addition; An error occurred for a non-digital characters, a numeric shape.

Add or decrease the date function: dateadd (to increase or decrease the date of date, increase or decrease, the date variable to increase)

Example: Calculating Test Date: DateAdd ("WW", 15, # 2002/3/19 #)

Date Date Date: Datediff (Date, Date, Date, Date)

Example: Calculation distance graduation days: datediff ("d", count, # 2005/6/30 #)

---------------------

SELECT CASE statement

SELECT CASE variable or expression

Case Expression List 1

Sentence block 1

Case Expression List 2

Statement block 2

......

[Case Else

Sentence block n 1]

End SELECT

1) Variables or expressions: can be numeric or string expressions.

2) Expression list i: can be an expression, a set of comma-separated enumeration values, expressions 1 TO expression 2, IS relational operator expression.

3) Variables that appear in "Variables or Expressions" in "Expression List I" are not available.

Example: Case 1 to 10case "a", "w", "e", "t" Case 2, 4, 6, 8, is> 10

FOR cycle statement (knowing a count cycle of the number of cycles)

FOR cycle variable = initial value TO final value [Step Step]

Statement block

[EXIT for]

Statement block

NEXT cycle variable

1) Number of cycles = INT (final value - initial value) / step length 1)

2) The final value is changed even if the value containing variables, the final value does not change with the value of the variable.

3) Step length> 0, initial value <= final value. Steps <0, initial value> = final value, default is 1.

WITH statement

With object name

Statement block

End with

Example: with form1

HEIGHT = 3000

Width = 4000

Backcolor = RGB (255, 0, 0) End with

转载请注明原文地址:https://www.9cbs.com/read-75928.html

New Post(0)