Tổng quan về thuộc tính END() trong VBA

  • Thread starter SA_DQ
  • Ngày gửi
Khóa học Quản trị dòng tiền
hai2hai

hai2hai

VNUNI Makes a difference
29/4/04
2,032
125
63
50
Hà nội
vnuni.net
Chưa xem nhưng nhìn tiêu đề đã có vấn đề. End() là method, ko phải là property (thuộc tính) nhé.
 
QDuc

QDuc

Cao cấp
3/6/06
254
18
18
Biển khơi
Chưa xem nhưng nhìn tiêu đề đã có vấn đề. End() là method, ko phải là property (thuộc tính) nhé.
Trong CS VBE, ta nhập chữ End(); Tô chọn nó & nhấn {F1}
Chọn dòng Excel, ta sẽ có
End Property
See AlsoApplies ToExampleSpecificsReturns a Range object that represents the cell at the end of the region that contains the source range. Equivalent to pressing END+UP ARROW, END+DOWN ARROW, END+LEFT ARROW, or END+RIGHT ARROW. Read-only Range object.

expression.End(Direction)
expression Required. An expression that returns one of the objects in the Applies To list.

Direction Required XlDirection. The direction in which to move.

XlDirection can be one of these XlDirection constants.
xlDown
xlToRight
xlToLeft
xlUp

Example
This example selects the cell at the top of column B in the region that contains cell B4.

Range("B4").End(xlUp).Select

This example selects the cell at the end of row 4 in the region that contains cell B4.

Range("B4").End(xlToRight).Select

This example extends the selection from cell B4 to the last cell in row four that contains data.

Worksheets("Sheet1").Activate
Range("B4", Range("B4").End(xlToRight)).Select

Nếu chọn dòng bên trên thì
sẽ là
End Statement


Ends a procedure or block.

Syntax

End

End Function

End If

End Property

End Select

End Sub

End Type

End With

The End statement syntax has these forms:

Statement Description
End Terminates execution immediately. Never required by itself but may be placed anywhere in a procedure to end code execution, close files opened with the Open statement and to clear variables.
End Function Required to end a Function statement.
End If Required to end a block If…Then…Else statement.
End Property Required to end a Property Let, Property Get, or Property Set procedure.
End Select Required to end a Select Case statement.
End Sub Required to end a Sub statement.
End Type Required to end a user-defined type definition (Type statement).
End With Required to end a With statement.



Remarks

When executed, the End statement resets all module-level variables and all static local variables in all modules. To preserve the value of these variables, use the Stop statement instead. You can then resume execution while preserving the value of those variables.

Note The End statement stops code execution abruptly, without invoking the Unload, QueryUnload, or Terminate event, or any other Visual Basic code. Code you have placed in the Unload, QueryUnload, and Terminate events of forms and class modules is not executed. Objects created from class modules are destroyed, files opened using the Open statement are closed, and memory used by your program is freed. Object references held by other programs are invalidated.

The End statement provides a way to force your program to halt. For normal termination of a Visual Basic program, you should unload all forms. Your program closes as soon as there are no other programs holding references to objects created from your public class modules and no code executing.
 
hai2hai

hai2hai

VNUNI Makes a difference
29/4/04
2,032
125
63
50
Hà nội
vnuni.net
Chắc Hai2Hai xài E2007, nên có khác; Mình đang xài E2003 mà; Thông cảm nha!:beernow::020::food-smil:lol::two:

Ah, Sorry bác SA-DQ, trong Excel nó có khái niệm hơi khác (vì hai2hai ko làm nên ko biết). Hai2hai ko dùng gì liên quan tới VBA hay Excel nên chỉ võ đoán thế. Không ngờ trong đó nó lại ghi là property nhỉ.

Nhưng mà theo đúng nguyên tắc thông thường thì thuộc tính là danh từ, còn even, function, procedurre hay method thì phải là động từ. Đây cũng là những nguyên tắc đặt tên trong lập trình (Naming convention) mà rất ít người áp dụng.
 
Sửa lần cuối:

Xem nhiều

Webketoan Zalo OA