Hàm trái VBScript
❮ Tham khảo VBScript hoàn chỉnh
Hàm Left trả về một số ký tự được chỉ định từ phía bên trái của chuỗi.
Mẹo: Sử dụng hàm Len để tìm số ký tự trong một chuỗi.
Mẹo: Ngoài ra, hãy xem hàm Right.
Cú pháp
Left(string,length)
Parameter | Description |
---|---|
string | Required. The string to return characters from |
length | Required. Specifies how many characters to return. If set to 0, an empty string ("") is returned. If set to greater than or equal to the length of the string, the entire string is returned |
Ví dụ
ví dụ 1
<%
txt="This is a beautiful day!"
response.write(Left(txt,15))
%>
Đầu ra của đoạn mã trên sẽ là:
This is a beaut
Hiển thị ví dụ »Ví dụ 2
Trả về toàn bộ chuỗi:
<%
txt="This is a beautiful day!"
x=Len(txt)
response.write(Left(txt,x))
%>
Đầu ra của đoạn mã trên sẽ là:
This is a beautiful day!
Hiển thị ví dụ »❮ Tham khảo VBScript hoàn chỉnh