Click to See Complete Forum and Search --> : How to call function


Squall Leonhart
12-03-2003, 12:22 PM
Hi, guys.

I want to ask you how to call function.
Please take a look at code.


<html>
<HEAD>
<SCRIPT LANGUAGE="VBSCRIPT">
Sub A1_OnClick
call whatever()
End Sub
</SCRIPT>
</HEAD>
<title>Create Excel on Server</title>
<body bgcolor="#FFFFFF">
<!--#Include file="functions.inc"-->
<INPUT TYPE=BUTTON NAME="A1" VALUE="A1 Create">

</body>
</html>


Clicking button will call the function in functions.inc file
-functions.inc

<%
Function whatever()
'Name of the access db being queried
accessdb="tech_re"
.......
End function
%>

But when I clicked the button, it says error message.
Type mismatch 'whatever'
But I checked spelling, nothing is wrong as you can see.
Can you guys see the problem? Thank you.

lillu
12-04-2003, 05:31 AM
Hi,

Seems like you are trying to mix client side and server side script, or I am wrong?

<html>
<script language="vbscript'>
...
</script>
</html> does look like client-side to me, from which you invoke the .inc file's function that resides on the server, right?

I would do this:

functions.inc

<%
Function whatever (args)

End Function
%>

<!-- #INCLUDE FILE="functions.inc"-->
<%
output=whatever(args)
%>
<html>
<body>
<p><%=output%> </p>
</body>
</html>

This way, you get the return values from the function server-side which you can output anywhere on the page.

Nicodemas
12-04-2003, 09:23 AM
In being that you have a call statement to a function, I would think the function needs to be a Sub if it isn't returning anything. Otherwise, I believe that all functions must be call in a normal expression.