Chức năng bên trái của VBScript


❮ Toàn bộ tài liệu tham khảo VBScript

Hàm Left trả về một số ký tự được chỉ định từ phía bên trái của một chuỗi.

Mẹo: Sử dụng hàm Len để tìm số ký tự trong một chuỗi.

Mẹo: Cũng nhìn vào chức năng Bên phải.

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

Các 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

Ví dụ 2

Trả lại 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!

❮ Toàn bộ tài liệu tham khảo VBScript