Global subroutine

J

John C

Hi all,

How can I create a Global subroutine.

I have the following local subroutine,

<script language="VBScript">
Sub PrintDetails(CompName, Discount)
document.writeln(Date)
document.writeln("Coupon from " & CompName)
document.writeln("Your discount is " & Discount & "% !!!")
End Sub
</script>

but needs to be called from many forms. Thus needs to be global visible!


How do I set that up?

TIA,
John
 
M

MD Websunlimited

Hi John,

Place in a script.vb file then use
<script language="VBScript" src="script.vb" >
</script>
 
J

John C

Thanks, but it doesn't seem to work. Must be me.

I have the following in my script file (name "scripts.vb" in same
directory):

<script language="VBScript">
Sub PrintDetails(CompName, Discount)
document.writeln(Date)
document.writeln("Coupon from " & CompName)
document.writeln("Your discount is " & Discount & "% !!!")
End Sub
</script>


and the following in my form-file:

<script language="VBScript" src="scripts.vb">
PrintDetails"My Company Ltd","10"
</script>


Any idea why this is not working? Error message refers to line 1 of the
scripts file.

TIA
John
 
J

John C

Hi Mike,

I still can't get it going. Please find my source below.

As you can see I have the Sub here in the same source file but the call to
subroutine (PrintDetails) refers to the script file at "c:\temp\scripts.txt"
When I remove the sub decleration from this source file, it can't find the
subroutine PrintDetails. So it seems to ignore the location reference "src="

Thanks very much for your help again in advance.

John

Main File:
----
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">

<script language="VBScript">
Sub PrintDetails(CompName, Discount)
document.writeln("Discount Coupon from " & CompName)
document.writeln("Your discount is " & Discount & "% !!!")
document.writeln("Valid till " & Date)
End Sub
</script>

</head>
<body>
<script language="VBScript" scr="c:\temp\scripts.txt">
PrintDetails"My Company Ltd","10"
</script>
</font>
</body>
</html>

----------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top