Windows Scripting
  Home arrow Windows Scripting arrow Page 4 - VBScript: Functioning with Strings
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: Functioning with Strings
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-04-14

    Table of Contents:
  • VBScript: Functioning with Strings
  • Checking If It’s In With the InStr() Function
  • Using InStr() with Variables
  • Uppercase and Lowercase

  • 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: Functioning with Strings - Uppercase and Lowercase


    (Page 4 of 4 )

    We use LCase() and UCase() to make a string lower case or upper case, respectively. Here is the LCase function at work:


    <html>

    <body>

    <script type="text/vbscript">

    dim small

    small="LOOK HOW BIG I AM!"

    document.write(LCase(small))

    </script>

    </body>

    </html>

    Even though the value in the variable “small” starts out fully capitalized, the result is:

      Look how big I am!

    You will note that you do not have to use a variable in order to use the LCase() function:


    <html>

    <body>

    <script type="text/vbscript">

    document.write(LCase("I AM A GIANT!"))

    </script>

    </body>

    </html>

    This prints out:

      i am a giant!

    The UCase() works in a similar fashion, only it makes everything upper case:

    <html>

    <body>

    <script type="text/vbscript">

    document.write(UCase("I am a giant!"))

    </script>

    </body>

    </html>

    The result:

      I AM A GIANT!

    If it sees that a letter is already upper case, it does not change it.

    You can also use UCase() on variables as well:


    <html>

    <body>

    <script type="text/vbscript">

    dim giant

    giant="i am a giant!"

    document.write(UCase(giant))

    </script>

    </body>

    </html>

    Again we have:

      I AM A GIANT!

    And finally, we can also mix the UCase() and LCase() together, like this:


    <html>

    <body>

    <script type="text/vbscript">

    dim giant

    giant="i am a giant!"

    document.write(UCase(giant)) & "<br />"

    document.write(LCase(giant))

    </script>

    </body>

    </html>

    This will print out:

      I AM A GIANT!

      i am a giant!

    One last thing on the UCase and LCase functions: you will note that the actual value of the object you use the functions on does not change. Observe this example:


    <html>

    <body>

    <script type="text/vbscript">

    dim giant

    giant="i AM a giant!"

    document.write(UCase(giant)) & "<br />"

    document.write(LCase(giant)) & "<br />"

    document.write(giant)

    </script>

    </body>

    </html>

    The print out is:

      I AM A GIANT!

      i am a giant!

      i AM a giant!

    As you can see, we printed out the value in “giant” to show that it remains unchanged, despite using the functions on it.

    Conclusion

    There are sixteen built-in functions for dealing with strings in VBScript and we have only touched upon four of them in this article. In the next tutorial we will cover more, if not all, of them. And in the weeks to come, we'll eventually conclude our discussion of functions altogether. So be sure to check back often.

    Till then…


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · You should have included the LIKE function. This function gives developers a...
       · Hey, thanks for the suggestion. I'll actually be doing an article on regex soon, and...
     

    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