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  
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: 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


    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

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