PDA

View Full Version : Static variables with vbs??



BexleyManor
03-12-2005, 09:03 AM
Hi all,

To get straight to the point, Is it possible for me to create a static variable with vbs??

When I do this with VBA,


Static tnow
tnow = Time + TimeSerial(0, 1, 0)
Do Until Time > tnow
MsgBox Time
Loop

Fine, it works, but in vbs I get an error. I therefore suspect the use of Static is not allowed in vbs. If this is the case, how can I get round this??

Many thanks in advance.

mdmackillop
03-12-2005, 09:21 AM
I tried your snippet in a VB6 form, and it ran without error.

BexleyManor
03-12-2005, 09:37 AM
I tried your snippet in a VB6 form

Indeed, but I'm only concerned with VBS not VB6 !!

Paleo
03-12-2005, 08:16 PM
There is no Static declaration in VBS and yes there is in VBA and VB 6, thats why it works on both.

I recommend you to check this site http://www.sunny-beach.net/manual/249.htm for differences between VB, VBA and VBScript.

BexleyManor
03-13-2005, 03:53 PM
Ok, thanks Carlos. I suspected this.

So, how do I get round this??

Any suggestions folks??

Paleo
03-13-2005, 09:40 PM
Hi,

just take the static off. You may use this:


<html>
<head>
<script language="VBScript">
Sub Test
tnow = Time + TimeSerial(0, 1, 0)
Do Until Time > tnow
MsgBox Time
Loop
End Sub
</script>
</head>
<body onload="Test">
Tested!
</body>
</html>

BexleyManor
05-11-2005, 03:27 PM
Thanks my friend, sorry for the delay in getting back. Spun off in an Excel charts whirlwind!!

Paleo
05-11-2005, 09:03 PM
You are welcome and thanks for the help on my post!:thumb