Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - VBScript: Conversion and Format 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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
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: Conversion and Format Functions
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2008-05-19

    Table of Contents:
  • VBScript: Conversion and Format Functions
  • The Asc() Function
  • CBool...CBool Run
  • CCur...Did I Stutter? Oh Yeah, I Guess I Did
  • This Next Part Will Make You CDbl()

  • 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: Conversion and Format Functions - CBool...CBool Run


    (Page 3 of 5 )

    As stated in our nifty table, the CBool function doesn't just sound like "See Bull," it also can be used to convert an expression to a boolean value. Basically, if the value you test is a numeric and not equal to 0, then CBool returns True. If the value is numeric and is equal to 0, the it returns false. Finally, if the value is not numeric at all, you get an error. So don't use it on non-numeric values. Got it chump?


    <html>

    <body>

    <script type="text/vbscript">

    dim num, num2, num3, txt2

    num=20

    num2=5*4

    num3=0

    txt2="592"

    document.write(CBool(num) & "<br />")

    document.write(CBool(num2)& "<br />")

    document.write(CBool(num3)& "<br />")

    document.write(CBool(txt2))

    </script>

    </body>

    </html>

    The result:

      True
      True
      False
      True

    Say we changed the value of txt2 to "Hello." If we had done this, you would either get an error message, or neither True nor False would have been returned.

    Take A CByte() Outta Crime

    The CByte function takes an expression and returns it as a Byte. Here, in this example, we will work with several decimals and a division to see what result CByte returns:


    <html>

    <body>

    <script type="text/vbscript">

    dim num, num2, num3

    num=.03356

    num2=12.5963

    num3=0.995

    num4= 9/2

    document.write(CByte(num) & "<br />")

    document.write(CByte(num2) & "<br />")

    document.write(CByte(num3)& "<br />")

    document.write(CByte(num4))

    </script>

    </body>

    </html>

    The result of this code is:

      0
      13
      1
      4

    More Windows Scripting Articles
    More By James Payne


       · Welcome back. In this article we will cover Conversion and Formatting functions. If...
     

    WINDOWS SCRIPTING ARTICLES

    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH
    - Advanced Word Object Scripting
    - Reading and Printing Word Documents in WSH
    - Scripting Microsoft Word
    - Using WSH to Catalog MP3 Files
    - Reading MP3 ID3 Tags in WSH
    - A Brief Look at Menus in WPF
    - More Examples of Simplified Image Processing...
    - Completing a WPF To-Do List Application
    - Simplified Image Processing in GDI+





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT