ASP Vbscript Left String Function

Updated on 02 Aug 2008, Published on 02 Aug 2008

In ASP, vbscript Left string function returns the substring of specified length starting from the left side of a string. You can use also the vbscript Len function to get the number of characters in the string that returns the string length. Vbscript len function enables you to get the position of last character and retrieve the substring starting from the left side of specified string upto the character position less than the length of the string.

 

Syntax for ASP Vbscript Left String Function

 

Left( string, length )

 

Vbscript Left function accepts two parameters as shows in above syntax. You can use the vbscript Len function to specify the length parameter of Left string function.

 

  1. string: this parameter accepts the string value or string type variable name.


  2. length: this parameter accepts the number value to specify the length for the substring to be returned by the vbscript left function starting from the left side of a string specified in the string parameter.

 

 

Examples of ASP Vbscript Left String Function

 

Example 1:

<%

 

Dim
myString

myString = "Vbscript Left String Function"

Response.Write(Left(myString, 15))

 

%>

 

Output:

Vbscript Left S

 

 

Example 2:

<%

myString = "Vbscript Left"

Dim length

' here reverse vbscript for loop with step -1 is used to pass the decreasing length dynamically for length parameter of Left string function.

for length = Len(myString) to 1 step -1

Response.Write(Left(myString, length))

Response.Write("<br />")

next

%>

 

Output:

Vbscript Left
Vbscript Lef
Vbscript Le
Vbscript L
Vbscript
Vbscript
Vbscrip
Vbscri
Vbscr
Vbsc
Vbs
Vb
V

Product Spotlight

Share it
Rate this article:
Email it:
email

0 Responses to "ASP Vbscript Left String Function"
Leave a Reply

Name   (Required)


Mail   (will not be published) (Required)


Website   (http://www.example.com)




OR Subscribe via Email:

Programming Ezine rss feed
Top54u Ezines