Community discussion forum

Calling a function from ASP code

Tags: asp Nigeria
  • 3 years ago

    Hi,

    Pls how do i call a function from ASP code and pass parameters to the function.

    Example:

    <%

    If Len(Request.Form("Resource")) > 0 Then

      (call a function)

    end if

    <%

  • 3 years ago

    Hi Sammy,

    There are lots of tutorials available on the web, my favourite sites being w3schools and 4guysfromrolla

    The example below demonstrates how to call a function:

    In the head of the ASP page:

    <SCRIPT LANGUAGE="vbscript" RUNAT="Server">
      dim cube       ' script-level variable           
       Sub CubeIt(x)
          cube = x^3
       end sub
    </SCRIPT>    


    You can then call your function from the body:

    <%



    Dim intVar
    intVar = 3
    CubeIt intVar
    Response.Write cube
    %>

    If you have any more queries or want me to clarify anything let me know.

    Regards,
    Bob 






















  • 3 years ago
    <%
    Function MyFunction(value)
        Dim return : return = ""
        return = "Your passed " & value & " into the function"
        MyFunction = return
    End Function

    'To write the return value:
    Response.Write(MyFunction("Some text"))

    'You could use "Sub" but sub's doesn't return values.
    'If you don't want to write the return to screen you could use;

    Call MyFunction("Some text")
    %>


    Hope this helps


    Courtenay Probert





















  • 4 months ago

    hi.. im not sure wther this comment are ady xpired or not..

    but i ihv to somethg..regarding to this topic also...how to we call fuction from ASP code, but in different pages.!!

    tq!!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!