Calling a function from ASP code

asp Nigeria
  • 15 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

    <%

  • 15 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 






















  • 14 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





















  • 11 years 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!!

  • 10 years ago

    well u can include the asp page ( where you have written the function) into any asp page using the script tag then we can call the function from this page as include returns the page completly into the calling page.

Post a reply

Enter your message below

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

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is anticipated with distaste, performed with reluctance, and bragged about forever.” - Dan Kaminsky