Archive for December, 2004

News Years Eve in review

Friday, December 31st, 2004 | Life

Well The Matrix disk has just entered by DVD player. It just wouldn’t be New Years Eve without it. I am not sure how the tradition got started for me but this is the 4th year I believe that I have watched the Matrix on New Years Eve and even though I can’t say it is the movie I would pick to watch, I would hate to break tradition.

I have also got Hell’s Kitchen to watch which has Angelina Jolie who played Lara Croft in the Tomb Raider movies. I bought it for myself at Christmas but haven’t watched it yet. So busy doing nothing and writing random news stories that I have done jack all holiday – I feel like I need a holiday from my holiday!

Anyway, I remember last New Years Eve I think it was that I watched Red Dwarf at like 1 in the morning followed by some carry on film or something. This year I can watch Red Dwarf on DVD as I got series 1 and I have one episode on it that I haven’t seen yet (well I have probably seen it ages ago but no recently or on the DVD). I also have some commentary to watch from episode 5.

I was actually going to do something this year though. I was going to head off to a party at Dean’s but we never got it organised. I really need more friends who aren’t nerds, but then again I would hate for people to think I was losing my nerdish routes. I do need to network though for a certain little project. That is going to be kept secret for the moment though.

Query strings not detected in ASP

Thursday, December 30th, 2004 | Programming, Tech

Problem: You are requesting QueryString’s in ASP but nothing happens and the value seems to be empty.

Cause: You cannot use default documents when requesting QueryString’s. For example:

Would pick up that the query string “q” is set to “hello.” However:

Would not pick up anything despite index.asp being loaded as the default document.

Fix: Enter the full url instead of skipping out the file name.

Opening pop-ups in Flash

Thursday, December 30th, 2004 | Programming, Tech

You can call JavaScript functions from your flash movie. This tutorial will show you how to call a pop up window opener function from your movie when a user clicks a button. You can create the html page in any text editor.

1. Create a simple button in Flash. You could also just drag one out of the shared library. You then need to open up the actions menu and insert the following code:

on (release) {

This code will call the JavaScript when a user clicks on the button. Once this is done goto File > Publish and publish your movie. Make sure the publish settings are set to publish the file with a html document.

2. Now you need the code for the JavaScript function.

<script language="JavaScript">
function popup() {'','','toolbar=no,location=no,directories=no,status=no,menubar=no,

This code can be modified. The first section is the page URI. The second section is your options such as do you want to make it resizable and have scrollbars. The first section has width, height and location from left and top in. Make sure the “” line and the line below are on the same line.

3. Now open your text editor and find the html file generated when you published your movie. Open it and insert the JavaScript function just below the tag. Now save the page.

4. Open the file in your browser. Clicking the button should now open up the pop up window.

Making your Flash movie transparent

Thursday, December 30th, 2004 | Programming, Tech

Making your movies transparent allows you to see the background on bits where there is nothing in the movie. However this is actually nothing to do with the settings in Flash when publishing movies. The trick is in the html file that the movie is added into.

Transparency in movies will only work in Internet Explorer 4+ and won’t work in Netscape.

To make your movies transparent, simply paste this code in between the HTML Object tags.

<param NAME="wmode" Value="transparent"

And so, the embedding code for the SWF file for the second example (transparent) is as follows:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ID="himalayas" WIDTH="250" HEIGHT="100">
<param NAME="movie" VALUE="himalayas.swf">
<param NAME="quality" VALUE="high">
<param NAME="wmode" Value="Transparent">
<embed src="himalayas.swf" quality="high" bgcolor="#FFFFFF"
WIDTH="250" HEIGHT="100" TYPE="application/x-shockwave-flash">

Note: the above source file doesn’t include some key information like the Base Code URL due to the text width limitations.


The transparency (as well as any other cool new technology) doesn’t work in Netscape at all. Use Internet Explorer to be able to view transparent Flash Content.

For the transparency effect to work as desired, don’t add a filler background element to your movies. Many developers add a large, white rectangular box, etc. to simulate white color. Make sure the drawing area behind the main movie is clear of any unwanted colours, etc (it will show up in the final animation).

Using timers in Visual Basic

Thursday, December 30th, 2004 | Programming, Tech

Timers are those little button things that appear on the wizard for the web browser from in Visual Basic 6. They control time. The first thing to note about them is that they are invisible at run time so you don’t have to worry about where you put them because the user won’t see a thing.

Timers, wait for a specific length of time and then execute the script they have. One of the first options they have is whether to start enabled or disabled. If it’s enabled it will begin timing and execute the script. If it is disabled then it won’t do anything.

Being able to disable it allows you to set it so it only does something once. For instance if you wanted it to wait 10 seconds and then say “hello,” but only do this once you could use this:

Create a timer object called “timer1.” This should happen automatically as timer1 is the default name. Set your time to enabled and set the time period to 10000. The timer is set to one thousandth of a second so 10,000 will make it time for ten seconds.

Next double click on the timer object to bring up your code box. And add in the following:

MsgBox ("Hello")
Timer1.Enable = False

When the timer reaches its time limit it runs the script. The first line just tells it to say “hello” in a message box. The second line disables itself by telling the object “timer1” to set its property, enable to false so that it is disabled.

A timer is also handy in things such as web browsers. Every tenth of a second you could set the timer to check whether a page has loaded and if so change the title of the form to the web browser’s page title.

If WebBrowser1.PageTitle <> Form1.Caption Then
Form1.Caption = WebBrowser1.PageTitle
End If

In this script you want to keep the timer permanently enabled so it will be constantly checking to see if the web browser’s page title and the text in the title bar of the forms are different and if so, update the forms title.

Adding data to the registry in Visual Basic

Thursday, December 30th, 2004 | Programming, Tech

This sample shows a bottom which when clicked changes the registry. The first three bits of information are the categorises in the registry while the final one is the value.

Private Sub button1_Click()
SaveSetting "My App", "Options", "Clicked", "Yes"
End Sub

You can also make the information dynamic. For instance if you wanted to save a users name you could have a text box called Name1. When the clicked a button it would then save the name they entered into the registry.

Private Sub button1_Click()
SaveSetting "My App", "Users", "Username", Name1.Text
End Sub

Reading from the Registry in Visual Basic

Thursday, December 30th, 2004 | Programming, Tech

In a previous article I showed you how to save settings in the registry. Now I’m going to show you how to get them back out again.

The basic syntax is as follows.

GetSetting("MyApp", "Category", "InfoName", "DefaultValue")

So lets look at the article on saving information in the registry. I used this example to save a username.

SaveSetting "My App", "Users", "Username", Name1.Text

Now, we’re going to pull this information out and and display the username in the title of the application. This code goes in the Load sub in your application. The name of the form we are working on is irrelevant because I used the term “me” which refers to the current form the code is on.

Me.Caption = "Weclcome " + GetSetting("MyApp", "Users", "Username", "To MyApp")

If no value is found in the registery, the default value is used so if no username was present, the applications title would be.

Welcome To MyApp

If the username in the register was “Jimbo” the applications title would be.

Welcome Jimbo

When using GetSettings you can’t use it on its own. You must use as as part of an equasion such as the example below.

A = GetSettings

You can also do the following.

If GetSettings = a Then do b

It simply supplies one piece of information from the Registry just like a variable.

Trapping errors in Visual Basic

Thursday, December 30th, 2004 | Programming, Tech

If you keep coming up with problems in your applications and you don’t want error messages to be popping up when the user causes an error then all you need to do is add an error handler. In fact, you should be doing this anyway, just in case errors come up.

On Error

There are two options from here. You can either get it to ignore the error or do something else that sorts the error out. If you just want the error to be ignored use this.

On Error Resume Next

This will simply execute the next line of code after one with the error on. This could stop your application doing something important but lets face it, however there are times when you legitimately want to stop an error and ignore it. Usually it is just used then there is a problem such as when you are using the web browser control and a user clicks back when there is no page to go back to. This would normally bring up an error box but by adding in the code it stops this from happening.

Your other alternative is to add in a GOTO command to send the code to do something else if it finds an error. Take a look at this example.

On Error Goto 10
Exit Sub
10 ' error bit
MsgBox ("Error!")
' some code to sort it out
End Sub

Turning a form button into a link using JavaScript

Thursday, December 30th, 2004 | Programming, Tech

Bored of ordinary links? Then try using buttons. This can work well if there are a series of them lined up in a navigation bar especially if you using image backgrounds or CSS styles to make them look good.

First of all, there is the script that goes into the head of your page.

<script language="JavaScript">
function goToURL() { window.location = ""; }

Amazingly simple. Your normal JavaScript tags with a link function. Now for the button which goes in your pages body tag:

<input type=button value="New JavaScripts" onClick="goToURL()" />

Of course, you should never use buttons, or JavaScript links, because they create usability problems. Also, this is also invalid HTML. But it will work in almost all browsers.

Suppressing JavaScript errors

Thursday, December 30th, 2004 | Programming, Tech

What is the most annoying thing you cant think of? Well ok, JavaScript error aren’t that annoying but nobody likes them. What we need is a simple script that stops all the JavaScript erros from appearing. This is a pretty simple script which is short so lets dive straight into the code.

function stoperror(){
return true

Just stick the script into the head tag. Although the above alert method is invalid (no closing quotations), no errors will be generated. This script will suppress all potential errors in a page, so be sure to turn it off while test running a script.

Of course, a much better solution, is to actually write JavaScript that works.