| HTML Tutorials |
|
|
| XML Tutorials |
|
|
| Browser Scripting |
|
|
| Server Scripting |
|
|
| .NET (dotnet) |
|
|
| Multimedia |
|
|
| Web Building |
|
|
| Java Tutorials |
|
|
| Programming Langauges |
|
|
| Soft Skills |
|
|
|
|
Create an ArrayList
|
|
Functions are like subprograms, except they talk back -- they return a data value to the calling statement and functions can be passed arguments, if needed, or they can operate without information being fed to them
|
|
Function Formats
|
|
The general format for a function is given below.
|
Function name (argument As type [, argument As type]...) [As type]
...statements
[Return value]
[Exit Function]
End Function
|
|
|
The following example shows a function named Get_Area which calculates the area of a rectangle and when supplied with height and width dimensions by the calling statement.
|
<SCRIPT runat="server">
Sub Rectangle
Dim Width As Integer = 10
Dim Height As Integer = 5
Dim Area As Integer
Area = Get_Area(Width, Height)
End Sub
Function Get_Area (Width As Integer, Height As Integer) As Integer
Get_Area = Width * Height
Exit Function
End Function
</SCRIPT>
|
|
|
Calling Functions from ASP.NET Pages
|
|
Very often rather than from a subprogram,a function is called from a server control coded on the page.
During data binding,this routinely happens.
A simple example is shown below where the current date is embedded on the page when it loads and the date is supplied by a function call.
|
<SCRIPT runat="server">
Sub Page_Load
Page.DataBind()
End Sub
Function Get_Date() As String
Get_Date = FormatDateTime(DateString, DateFormat.LongDate)
End Function
</SCRIPT>
<b>Today's date is <%# Get_Date %></b>
|
|
|
The binding expression <%# Get_Date %> is a
call to the function, whose returned value replaces the call when
Page.DataBind() is executed in the
Page_Load procedure and similar function calls are
made when binding calculated data to <asp:Repeater>,
<asp:DataGrid>, and <asp:DataList>
controls.
|
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords:
Functions in VB.NET,
visual basic functions,
vb net functions,
functions in vb net,
pl sql functions,
function in vb net,
substring in vb net,
string functions in vb net,
split function in vb net,
format function in vb net,
date functions in vb net,
date function in vb net,
php functions,
perl functions,
javascript functions,
oracle functions,
derivative functions,
calculus functions,
vb6 functions
|
|
| HTML Quizes |
|
|
| XML Quizes |
|
|
| Browser Scripting Quizes |
|
|
| Server Scripting Quizes |
|
|
| .NET (dotnet) Quizes |
|
|
| Multimedia Quizes |
|
|
| Web Building Quizes |
|
|
| Java Quizes |
|
|
| Programming Langauges Quizes |
|
|
| Soft Skills Quizes |
|
|
|