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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 4
    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


    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

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT