VBScript Left Function
❮ การอ้างอิง VBScript ที่สมบูรณ์
ฟังก์ชัน Left ส่งกลับจำนวนอักขระที่ระบุจากด้านซ้ายของสตริง
เคล็ดลับ:ใช้ฟังก์ชัน Len เพื่อค้นหาจำนวนอักขระในสตริง
เคล็ดลับ:ดูฟังก์ชันขวาด้วย
ไวยากรณ์
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 |
ตัวอย่าง
ตัวอย่าง 1
<%
txt="This is a beautiful day!"
response.write(Left(txt,15))
%>
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
This is a beaut
ตัวอย่าง 2
ส่งคืนสตริงทั้งหมด:
<%
txt="This is a beautiful day!"
x=Len(txt)
response.write(Left(txt,x))
%>
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
This is a beautiful day!
❮ การอ้างอิง VBScript ที่สมบูรณ์