Thursday, March 28, 2024

So You Want A VBScript, Huh?

     Please Note! This tutorial deals with VBScript and Active X discussions. In order to use or see the script perform, you need to be running Microsoft Explorer.

…use these to jump around or read it all


[VBScript, Joe?][What Is It?][Active X vs. Java]
[What is Happening?][The First Object]
[The Second Object][Adding It To Your Page]
[When Do I Use VBScript?]
































Might you have the time?




VBScript, Joe?


     Yup. See that thing right above – that purple thing telling you the time? That’s a VBScript. If you don’t see it, my guess is that you’re using Netscape sans plug-in. In order to join in the fun, you need Explorer or a version of Netscape that has an Active X plug-in.
     To get the Active X plug-in for Netscape, go to www.ncompasslabs.com.


What Is It?

     “VBScript” is a nice short way of stating Microsoft’s Visual Basic Scripting. It is a strict sub-set (little portion) of the Visual Basics for Applications (VBA) language. (huh?) It’s the Microsoft version of Java (sort of). (oh) And it’s the leading scripting language used in Active X.


Active X vs. Java


     Around 1995 0r 96 – someone said, “Let there be motion on WWW Pages!!!” Someone else seconded the motion and everyone went off looking for a simple programming language to do it. The first one that really took was Java. It’s an object oriented programming language created by a guy named James Gosling at Sun Microsystems. Read more about Java in my tutorial The Difference between Java and Java Script. This was a nice programming that allowed for some pretty interesting movement. It also ran other little programs like counters or image maps.


     Where Active X comes in is through Bill Gates and the fine people at Microsoft. Active X is Microsoft’s vision for interactive and movement-filled web pages. I’ve used it a couple of times. It’s actually pretty easy to use. One of the problems with Java is that you still need to write it out. Active X attempts to get rid of that. You can call up some activity (an “object”) with the click of a button. It’s all pretty slick. One drawback though.



It only works on Microsoft Explorer, or Netscape with plug-in.


     And probably only will for a few generations.
Why? Because there is no real need to have it work everywhere, Java is supported by Explorer and Netscape. What Microsoft is pushing is ease – not something new and better.


     Let’s take a look at the script:






<SCRIPT LANGUAGE=”VBScript”>

<!–

Sub IeTimer1_Timer()

IeLabel1.Caption = time

end sub

–>

</SCRIPT>

<OBJECT ID=”IeTimer1″ WIDTH=39 HEIGHT=39

 CLASSID=”CLSID:59CCB4A0-727D-11CF-AC36-00AA00A47DD2″>

   <PARAM NAME=”_ExtentX” VALUE=”1005″>

   <PARAM NAME=”_ExtentY” VALUE=”1005″>

   <PARAM NAME=”Interval” VALUE=”1000″>

</OBJECT>

<TABLE BORDER=2 BGCOLOR=PURPLE>

<OBJECT ID=”IeLabel1″ WIDTH=137 HEIGHT=39

 CLASSID=”CLSID:99B42120-6EC7-11CF-A6C7-00AA00A47DD2″>

   <PARAM NAME=”_ExtentX” VALUE=”3625″>

   <PARAM NAME=”_ExtentY” VALUE=”1005″>

   <PARAM NAME=”Caption” VALUE=””>

   <PARAM NAME=”Angle” VALUE=”0″>

   <PARAM NAME=”Alignment” VALUE=”4″>

   <PARAM NAME=”Mode” VALUE=”1″>

   <PARAM NAME=”FillStyle” VALUE=”0″>

   <PARAM NAME=”FillStyle” VALUE=”0″>

   <PARAM NAME=”ForeColor” VALUE=”#000000″>

   <PARAM NAME=”BackColor” VALUE=”#C0C0C0″>

   <PARAM NAME=”FontName” VALUE=”Arial”>

   <PARAM NAME=”FontSize” VALUE=”12″>

   <PARAM NAME=”FontItalic” VALUE=”0″>

   <PARAM NAME=”FontBold” VALUE=”1″>

   <PARAM NAME=”FontUnderline” VALUE=”0″>

   <PARAM NAME=”FontStrikeout” VALUE=”0″>

   <PARAM NAME=”TopPoints” VALUE=”0″>

   <PARAM NAME=”BotPoints” VALUE=”0″>

</OBJECT>

</TABLE>






What Is Happening


     First look at the text above. The actual “script” is quite small. It’s only three lines long. What follows is two
OBJECTS. See that above? The command <OBJECT> starts off each one.
To understand why, let’s go back to 1991. That’s when Microsoft began playing with this format they called OLE, Object Linking and Embedding. It was a way to create documents (spread-sheets mostly) that would allow many different working parts to all be stuck within the same domain. The parts would all do different things, and they would all work together. A good idea. Each part was referred to as an OBJECT. Each independent and each fully functioning.


The First Object


Looks like this:


<OBJECT ID=”IeTimer1″ WIDTH=39 HEIGHT=39

 CLASSID=”CLSID:59CCB4A0-727D-11CF-AC36-00AA00A47DD2″>




     Notice each object has its own ID name and parameter settings. Just like Java, these little guys need to have their own defined space. The class ID denotes a specific thing that this object does. In this case, it sets up a timer. See the name, “IeTimer1?” It also tells Explorer that it may need more power.

     Some of you may have noticed that you were asked to “sign” little contracts when you tried to access this page. The reason is that this VBScript is one that is not fully recognized by Explorer until some extra little programs are installed. When you said OK to the download, the Explorer browser got the needed programming and installed it.
It’s a truly slick little system.


The Second Object


Looks like this:

<TABLE BORDER=2 BGCOLOR=PURPLE>

<OBJECT ID=”IeLabel1″ WIDTH=137 HEIGHT=39

 CLASSID=”CLSID:99B42120-6EC7-11CF-A6C7-00AA00A47DD2″>



     …with a whole lot of parameter names.


     This is the actual look of the clock face. Thus the name, “IeLabel1.” Note that this Object is the one encased in the TABLE. Here you can change background color, change text color, change font type, font name, and add a caption if you want. Each of the parameters are fairly self-explanatory. Feel free to change them around and add new colors and text styles. The Object will respond.


Adding It To Your Page


     You can grab the entire VBScript from above. Just cut and paste. Just be sure to have it all: the script, and both objects. Without all three entities, this pup won’t work.


     Also remember that if you will probably have to post the script to try it out. Certain entities are being called for. So post it before you look at it to see if it works. It probably won’t run right off of the hard drive.


When Do I Use VBScript?


     When you are positive that your viewer will be using Explorer as their browser. If you’re not sure – use Java Script. Both script formats are supported by Explorer, but only Java Script is supported by Netscape.

     Keep in mind though, if your page is complete without the VBScript, go ahead and use it. Netscape is wonderful at ignoring commands it doesn’t understand. For example, if you use the clock above, people using Explorer get the time. People using Netscape get nothing. That’s not bad if the clock is just a little added extra for the Explorer crowd. See what I mean?


     That puts the finishing touches on another Explorer tutorial. I use both Netscape and Explorer, and I like them both. To have a preference so strong that you refuse to use one or the other is beyond me. It’s my opinion, if you’re into HTML – learn it all.



[VBScript, Joe?][What Is It?][Active X vs. Java]
[What is Happening?][The First Object]
[The Second Object][Adding It To Your Page]
[When Do I Use VBScript?]

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Popular Articles

Featured