BrainDump
  Home arrow BrainDump arrow Page 2 - VBScript: Plain and Simple
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 
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? 
BRAINDUMP

VBScript: Plain and Simple
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2007-12-03

    Table of Contents:
  • VBScript: Plain and Simple
  • Writing Our First VBScript
  • Variables...In....Space!
  • Arrays

  • 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: Plain and Simple - Writing Our First VBScript


    (Page 2 of 4 )

    If you have ever read anything about any programming languages they give you that really dumb "Hello World" program. We're not going to do it. The world can go find someone else to say hello to for all we care. So let's write a real program, a man's program, a man's man type of program, one that chews tobacco, smokes beer, and drinks nicotine:


    <html>

    <body>

    <script type="text/vbscript">

    document.write("Angelina Jolie leave that nerd Brad Pitt.")

    </script>

    </body>

    </html>

    Okay Einstein, let's see if you can guess what the output would be. Give up? Well this is what that little snippet of code would have printed out:

      Angelina Jolie leave that nerd Brad Pitt.

    In the above code, you will notice several things: 

    1. We wrote VBScript inside our HTML (hence me suggesting you go and learn it if you don't already know it).
    2. You must use the <script type="text/vbscript"> in your code. This is what tells your browser what language you are speaking in. Without it, it will think you are speaking Swahili.
    3. The way we write text to the browser is with document.write.

    Another thing you may have noticed if you are familiar with other programming languages is that you do not end statements with the semi-colon (;). In VBScript, the end of a statement is when you start a new line. This, of course, can be somewhat problematic as you could guess. Let's say we wanted to say more to Angelina. Well, we couldn't simply just type on forever. We could do this:


    <html>

    <body>

    <script type="text/vbscript">

    document.write("Angelina Jolie leave that nerd Brad Pitt.")

    document.write(" What does he have that I don't?")

    document.write(" Aside from looks, money, and a six-pack of abs.")

    document.write(" I have a six pack of Mountain Dew...")

    </script>

    </body>

    </html>

    This would print out

       Angelina Jolie leave that nerd Brad Pitt. What does he have that I don't? Aside from looks, money, and a six pack of abs. I have a six pack of Mountain Dew...

    You could also achieve the same affect using concatenation (or joining) "&" and the multiple line special character (the underscore"_"). Here it is in code.


    <html>

    <body>

    <script type="text/vbscript">

    document.write("Angelina Jolie leave that nerd Brad Pitt." &_

    " What does he have that I don't? " &_

    "Aside from looks, money, and a six-pack of abs. " &_

    "I have a six pack of Mountain Dew...")

    </script>

    </body>

    </html>

    This code results in the same thing as our above code:

      Angelina Jolie leave that nerd Brad Pitt. What does he have that I don't? Aside from looks, money, and a six pack of abs. I have a six pack of Mountain Dew...

    More BrainDump Articles
    More By James Payne


       · Hey, James. That's a nice intro piece. Being a VBS author myself, I understand how...
       · Here we are yet again. Thanks for stopping by and reading yet another masterpiece by...
     

    BRAINDUMP ARTICLES

    - Microsoft Office SharePoint Server
    - Microsoft Office SharePoint Designer
    - Microsoft Windows SharePoint Services 3.0
    - Microsoft Live Mesh Overview
    - XAML Brushes and Silverlight
    - Silverlight and XAML Basics
    - Immortal XP
    - XAML Basics
    - Microsoft Surface
    - Making Your First Active X Control in Visual...
    - Codes and Packages in Microsoft Project 2007
    - Windows 7: Rumors and Demos
    - XP SP3 Why Me?
    - Breaking Up Your Work in Microsoft Project
    - Breaking Work into Task-Sized Chunks





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