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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
JMSL Numerical Library 
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: 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

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    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

    - Understanding Procedures in VBScript
    - Printing Documents in WSH
    - 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





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