Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass more than 1 arguement??

Status
Not open for further replies.

JanS

Technical User
Feb 21, 2001
77
AU
Hi,

I am having trouble passing more than 1 arguement to a procedure. Whenever I try more than 1, I get the following message:

"Cannot use parentheses when calling a Sub"

Any ideas what I am doing wrong? Code is below

Thanks in advance
jan

Working code with 1 arguement:

<script language=&quot;vbscript&quot;>
<!--
sub Page_init(arg1)
msgbox arg1
end sub
-->
</SCRIPT>

<HEAD>
<META name=GENERATOR Content=&quot;Microsft Visual Studion 6.0&quot;>
</HEAD>
<BODY BGCOLOR=#c6c6c6 ONLOAD=&quot;vbscript:page_Init('a')&quot;>

</BODY></HTML>


Here's what I try with 2 arguments but get the error above:

<script language=&quot;vbscript&quot;>
<!--
sub Page_init(arg1, arg2)
msgbox arg1
msgbox arg2
end sub
-->
</SCRIPT>

<HEAD>
<META name=GENERATOR Content=&quot;Microsft Visual Studion 6.0&quot;>
</HEAD>
<BODY BGCOLOR=#c6c6c6 ONLOAD=&quot;vbscript:page_Init('a','b')&quot;>

</BODY></HTML>
 
Hi,

error itself is giving u the clue. In VBScript when u are calling a sub u should not pass arguments in '()' when u r not using &quot;call&quot;.

In u'r case use :

<BODY BGCOLOR=#c6c6c6 ONLOAD=&quot;vbscript:call Page_Init('a')&quot;>
and
<BODY BGCOLOR=#c6c6c6 ONLOAD=&quot;vbscript:call Page_Init('a','b')&quot;>

 
I should have said that I have tried this both with and without &quot;call&quot; , with and without the brackets - same error no matter how I format the statement.

Anymore ideas??????
Thanks
jan
 
Hey it is working woth me as :

<HTML>

<HEAD>
<META name=GENERATOR Content=&quot;Microsft Visual Studion 6.0&quot;>
<script language=&quot;vbscript&quot;>
private sub Page_init(arg1)
msgbox arg1
end sub
</SCRIPT>
</HEAD>
<BODY BGCOLOR=#c6c6c6 ONLOAD=&quot;vbscript:call Page_Init('a') &quot;>
<BR>srinu test<BR>
</BODY>
</HTML>
 
yep - one argument/parameter does work for me too. I need to pass at least 2, possibly three. As soon as I add a second, the error regarding the parentheses starts occuring.

Can you add another and see if your code still works???

jan
 
Works for me:
Code:
<HTML>               
<HEAD>
<META name=GENERATOR Content=&quot;Microsft Visual Studion 6.0&quot;>
<script language=&quot;vbscript&quot;>
<!--
Sub Page_Init(arg1, arg2)
    MsgBox arg1 & &quot;--&quot; & arg2
End Sub
-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=#c6c6c6 ONLOAD=&quot;Page_Init 'a', 'b'&quot;>
<INPUT TYPE=BUTTON VALUE=BUTTON ONCLICK=&quot;Page_Init 'a', 'b'&quot;>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top