Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - VBScript: More String Functions
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

VBScript: More String Functions
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-04-21

    Table of Contents:
  • VBScript: More String Functions
  • Left Behind
  • Right Ahead
  • The Middle Man
  • Left, Right, Mid…Using Them in a Stupid Way
  • Space() Not Really the Final Frontier After All

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    VBScript: More String Functions - Left Behind


    (Page 2 of 6 )

    The Left() function is used to return a number of strings you specify from the left hand side of the string. For instance, if my string contains the sentence: “Yo mama so ugly she made an onion cry” and we tell the program to return the first seven characters, it will result in: “Yo mama.” I know, I know. That’s only six characters. VBScript counts spaces as characters also; you'll want to keep that in mind. Here is how it looks in code:


    <html>

    <body>

    <script type="text/vbscript">

    document.write(Left("Yo mama so ugly she made an onion cry",7))

    </script>

    </body>

    </html>

    Giving you:

      Yo mama

    You can also use the Left() function on variables as well:


    <html>

    <body>

    <script type="text/vbscript">

    dim ugly

    ugly="Yo mama so ugly she made an onion cry"

    document.write(Left(ugly,10))

    </script>

    </body>

    </html>

    Here we dim and assign a value to the variable “ugly” and use Left() to parse and print out the first ten characters, resulting in:

      Yo mama so

    Note that if you specify more characters than are in the string, it will simply print out the whole string:


    <html>

    <body>

    <script type="text/vbscript">

    dim ugly

    ugly="Yo mama so ugly she made an onion cry"

    document.write(Left(ugly,10000))

    </script>

    </body>

    </html>

    Our result:

      Yo mama so ugly she made an onion cry

    More Windows Scripting Articles
    More By James Payne


       · Thanks for dropping by for another episode in our series on VBSCript String...
     

    WINDOWS SCRIPTING ARTICLES

    - Generating Outlook Signatures Based on Activ...
    - VBScript: Converting and Formatting with Fun...
    - VBScript: Conversion and Format Functions
    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...
    - VBScript: More String Functions
    - VBScript: Functioning with Strings
    - Working with the Windows Registry in C++
    - Understanding Objects
    - HTML Applications: Giving WSH a User Interfa...
    - Modifying Computer Objects with Active Direc...
    - Logon Script to Send Email Notifications
    - Securing Computers and Active Directory
    - Moving and Renaming Computers with Active Di...
    - Working with System Processes in WSH





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway