-Collapse +Expand

To/From Code

-Collapse +Expand Languages
-Collapse +Expand Categories
   PrestwoodBoardsTo/From GuidesReferenceCommands   

Left of String (Cross Ref > Commands)

Left of String

Access VBA:   Left

Syntax Example:
Dim LeftString As String
LeftString = Left("Prestwood", 3)
MsgBox LeftString


More Info

ASP Classic:   Left

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

More Info

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));


More Info

Delphi:   LeftStr

Syntax Example:
Uses StrUtils;
ShowMessage(LeftStr('Prestwood', 3));

More Info

Delphi Prism:   Substring

Syntax Example:
MessageBox.Show("Prestwood".Substring(0, 3));

More Info

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);
document.write(sName);
Syntax Example:
var sName;
sName = "Mike Prestwood";
sName = sName.substr(0, 6);
document.write("Hello " + sName);

More Info

ObjectPAL:   subStr

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

Alternative syntax:

LeftString = subStr(NameVar, 1, 3)
Syntax Example:
var
�LeftString String;
  NameVar String;
endVar
NameVar = "Prestwood"
LeftString = NameVar.subStr(1, 3)
msgInfo("", LeftString)

More Info

VB Classic: 

Syntax Example:
Dim LeftString As String
LeftString = Left("Prestwood", 3)
MsgBox LeftString

More Info

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))

More Info






Sponsored Ad
Brought to you by Prestwood IT Solutions,  Content by Mike Prestwood (owner of Prestwood IT Solutions)

We hope you are enjoying Mike's cross reference language encyclopedia! Our company is the caretaker of PrestwoodBoards.com where we pay our staff to moderate, edit, and participate. Why? Online participation is fun, we enjoy sharing information, and this is our way of promoting our I.T. services company.

We provide coding, website, and computer tech services. Keep us in mind if you or your company needs help.

Talented Developer?
If you are a talented developer and would like to work with us, start by filling out our Register for Work form.
 
822 People Online Now!!  
Online Now: Sign In to see who's online now!  Not a member? Join Prestwood now. It's free!