<%@ Page Language="VB" AutoEventWireup="false" CodeFile="例3-4.aspx.vb" Inherits="实训三_例3_4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Script language="VB" runat="server">
Sub pingfanghe(ByVal a As Integer, ByVal b As Integer, ByRef sum As Long) '首先定义Sub过程,用来计算a到b的平方和
Dim I As Integer
For I = a To b
sum = sum + I ^ 2
Next
End Sub
Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs) '然后在主代码中,用Call语句调用该过程
Dim m, n As Integer
Dim total As Long
m = 3
n = 5
Call pingfanghe(m, n, total)
message.Text = "3到5的平方和是:" & CStr(total)
End Sub
</Script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Sub过程定义与调用实例,求a到b的</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="message" runat="server" BackColor="#FFE0C0" BorderColor="Silver" BorderStyle="Solid" BorderWidth="2px" ></asp:Label></div>
</form>
</body>
</html>
这是源文件,是动态的!
但浏览时,没结果,而把第一行“
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="例3-4.aspx.vb" Inherits="实训三_例3_4" %>
”删除之后就可以浏览了
╮(╯▽╰)╭!不说了,无语了,本来写了一大段,想想还是删除的好!
问题的主旨是MS的Code Behind模型和你ASP的习惯,二者保留其一最好,如果都要留着那只能是找到自己认为的最优点就好
很难的问题。。。如楼上所说,你要用code-behind就别在页面是注册Page_Load这样的实践。把所有代码转移到code文件里去。
确实很难 嘿嘿