Say I want a function called adder, that does the following
public function adder(number1 as integer, number 2 as integer) as integer
dim result as integer = number1 + number2
return result
end function
Where would I write this function, and where would I keep it in my web app (app_code?) so that I can call it from any webform page in any event.
Thanks!
In class1.vb that lives in the App_Code folder
Public Module MyCommon
public function adder(number1 as integer, number 2 as integer) as integer
dim result as integer = number1 + number2
return result
end function
End Module
in the whatever.aspx.vb
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim foo As integer
foo = MyCommon.adder(12,22)
End Sub
Create a class in your App_Code folder, then when you need to access the function, you can just create a new instance of your class and call the function.
thanks to both of you. you wouldn't think I'd already written a massive app!
Already been doing this all the way through will BLL classes and functions - wasn't sure if it was the same or not
cheers guys!
0 comments:
Post a Comment