日期:2009-01-03  浏览次数:20527 次


    由于Function 程序有传回值,所以也可以当成数据源来提供数据。下列范例将Label Web 控件利用数据系结叙述,取得程序传回值的数据:


<Html>
<ASP:Label Id="Label1" Text='<%#"2 的平方为" + Squ(2)%>'
Runat="Server"/>
<Script Language="VB" Runat="Server">
Sub Page_Load(Sender As Object, e As EventArgs)
Page.DataBind()
End Sub
Public Function Squ(intA)
Return (intA*intA).ToString
End Function
</Script>
</Html>

上述范例除了接收Function 所传回的结果外,并且在数据系结叙述中将两个字符串以字符串结合运算子「+」作结合。