Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesASP ClassicCommands  Print This     

ASP Classic Commands

Left of String

ASP Classic:   Left
Syntax Example:
Dim LeftString
LeftString = Left("Prestwood", 3)
Response.Write LeftString

Cross Reference Examples:

Access VBA:   Left
Syntax Example:
Dim LeftString As String
LeftString = Left("Prestwood", 3)
MsgBox LeftString
C#:   Substring

Above returns "abcd" on a string literal. You can, of course, use VarName.Substring(0, 4).

Syntax Example:
Console.WriteLine("abcdefgh".Substring(0, 4));
Corel Paradox:   subStr

substr ( const startIndex LongInt [ , const numberOfChars LongInt ] ) String

Alternative syntax:

LeftString = subStr(NameVar, 1, 3)
Syntax Example:
�LeftString String;
  NameVar String;
NameVar = "Prestwood"
LeftString = NameVar.subStr(1, 3)
msgInfo("", LeftString)
Delphi:   LeftStr
Syntax Example:
Uses StrUtils;
ShowMessage(LeftStr('Prestwood', 3));
Delphi Prism:   Substring
Syntax Example:
MessageBox.Show("Prestwood".Substring(0, 3));
JavaScript:   substr

Above returns "Mike P".

SubStr(StartIndex, NumberOfCharacters)

Notice JavaScript is 0 based (the first character is character 0).�0 is start character, 6 is number�of characters).�

You can also use substring where both numbers are indexes:

SubString(StartIndex, EndIndex)

The following returns "re".

var sName;
sName = "Mike Prestwood";
sName = sName.substring(6, 8);
Syntax Example:
var sName;
sName = "Mike Prestwood";
sName = sName.substr(0, 6);
document.write("Hello " + sName);
VB Classic: 
Syntax Example:
Dim LeftString As String
LeftString = Left("Prestwood", 3)
MsgBox LeftString
VB.Net:  "Left of Substring" Left or Substring

The above usage of Left and Substring are equivalent.

Left is a traditional VB approach popular with developers moving from VB Classic to VB.Net. Substring is considered the .Net way of doing string manipulation.

Syntax Example:
Dim FullName
FullName = "Prestwood"
Console.WriteLine("Hello " + Left(FullName, 4))
Console.WriteLine("Hello " + FullName.Substring(0, 4))

Sales Website: Or visit our legacy sales site:

©1995-2024 Prestwood IT Solutions.   [Security & Privacy]