Source: http://blog.csdn.net/alexbnlee/article/details/6923787
→ The Type statement is required for custom data types.
Type lianxiren name As String sex As String age As Integer phone As String address As String department As StringEnd TypeSub AddressList() Dim record As lianxiren record.name = "Alex" record.sex = "Male" record.age = 23 record.phone = "18812345678" record.address = "Blahblah" record.department = "Blahblah" MsgBox record.nameEnd Sub
A custom data type is created before, and can be referenced later.
→ A system constant is a constant defined in the VBA system. It generally starts with a prefix of Vb.
For example, VbRed and VbOKOnly ~
→ Object data indicates the reference of an Object. The stored content is the address of an Object. When an Object variable is assigned a value, the copy statement cannot be used directly, instead, the Set statement should be used to assign values to it.
Dim Sheet As Object
Set Sheet = Worksheets ("sheet1 ")
→Is compares whether two Object variables are applied to the same variable. If the same variable Is used, True Is returned; otherwise, False Is returned.
→ Like example (similar to replacement in Word)
Dim MyCheckMyCheck = "aBBBa" Like "a * a" 'returns True. MyCheck = "F" Like "[A-Z]" 'returns True. MyCheck = "F" Like "[! A-Z] "'returns False. MyCheck = "a2a" Like "a # a" 'returns True. MyCheck = "aM5b" Like "a [L-P] # [! C-e] "'returns True. MyCheck = "BAT123khg" Like "B? T * "'returns True. MyCheck = "CAT123khg" Like "B? T * "'returns False.
→ Pause statement, Stop statement, the statement will Stop at the Stop position, and then press run to continue running... A semicolon can also be used to connect strings, and spaces are added to the left and right sides of numbers.
Sub Stop1 () Dim I As Integer For I = 1 To 5 Debug. Print "program No."; I; "pause" Stop NextEnd Sub