Windows Scripting
  Home arrow Windows Scripting arrow Page 4 - VBScript: Strings, You Can`t Function with...
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: Strings, You Can`t Function without Them
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-04-28

    Table of Contents:
  • VBScript: Strings, You Can`t Function without Them
  • LTrim That Hair You Hippie!
  • Trim()ming the Fat
  • Comparing Strings
  • The String Function
  • StrReverse()

  • 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: Strings, You Can`t Function without Them - Comparing Strings


    (Page 4 of 6 )

    You can compare strings in VBScript using StrComp(). It does two types of comparisons, a textual and a binary. Binary is the default. If you want to use binary you can either leave it blank or use 0. If you want textual, use -1. Just a brief note here. "WORD" does equal the same value as "word" in a textual search, but does not equal the same thing in a binary search, so always keep this in mind.

    The results returned from a comparison are:

    • -1: FirstString is less than SecondString

    • 0: FirstString is equal to SecondString

    • 1: FirstString is greater than SecondString

    • Null: One of the strings has a null value

    Here it is at work:


    <html>

    <body>

    <script type="text/vbscript">

    document.write(StrComp("Burger King","Burger King")) & "<br/>"

    document.write(StrComp("Burger King","Burger King",0))& "<br/>"

    document.write(StrComp("Burger King","burger king",0))& "<br/>"

    document.write(StrComp("Burger King","Burger King",1))& "<br/>"

    document.write(StrComp("Burger King","burger king",1))& "<br/>"

    document.write(StrComp("Burger King","McDonald's",0))& "<br/>"

    document.write(StrComp("burger king","Burger King",0))& "<br/>"

    document.write(StrComp("wendy's","Burger King",1))& "<br/>"

    </script>

    </body>

    </html>

    The results:

      0
      0
      -1
      0
      0
      -1
      1
      1

    More Windows Scripting Articles
    More By James Payne


       · Thanks for stopping by to read my article on String functions in VBScript. Here we...
     

    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 5 Hosted by Hostway
    Stay green...Green IT