dim t as object = new button()
t.click = ckpass()提示这句出错,我不知道该怎么解决,望高手赐教,谢谢
function ckpass()
end function
实验楼上仁兄,全部代码如下
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
<script language="vb" runat="server">
sub page_load(byval sender as object,byval e as eventargs)
dim b as object = new button()
b.text = "hello"
addhandler b.click,b_click
lable1.Controls.add(b)
end sub
Private Sub b_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
msgbox("TEST!!!")
end sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>fate stay night</title>
</head>
<body><form runat = "server">
<asp:label id = lable1 runat =server/>
<asp:label id = label2 runat = server/>
</form></body>
</HTML>
运行结果如下:
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: BC30455: 没有为“Private Sub b_Click(sender As Object, e As System.EventArgs)”的参数“e”指定参数。
源错误:
行 7: b.text = "hello"
行 8:
行 9: addhandler b.click,b_click
行 10: lable1.Controls.add(b)
行 11: end sub
源文件: E:\jsjj\Default.aspx 行: 9
|
使用zhangweI老兄答案,代码如下
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
<script language="vb" runat="server">
public dim b as object = new button()
sub page_load(byval sender as object,byval e as eventargs)
b.text = "hello"
b.id = "b"
lable1.Controls.add(b)
end sub
Private Sub b_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b.Click
msgbox("TEST!!!")
end sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>fate stay night</title>
</head>
<body><form runat = "server">
<asp:label id = lable1 runat =server/>
<asp:label id = label2 runat = server/>
</form></body>
</HTML>
执行结果如下:
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: BC30506: Handles 子句需要 WithEvents 变量。
源错误:
行 12: end sub
行 13:
行 14: Private Sub b_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b.Click
行 15: msgbox("TEST!!!")
行 16:
源文件: E:\jsjj\Default.aspx 行: 14
|
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
<script language="vb" runat="server">
public dim b as object = new button()
sub page_load(byval sender as object,byval e as eventargs)
b.text = "hello"
b.id = "b"
addhandler b.click, addressof b_click
lable1.Controls.add(b)
end sub
Private Sub b_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
msgbox("TEST!!!")
end sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>fate stay night</title>
</head>
<body><form runat = "server">
<asp:label id = lable1 runat =server/>
<asp:label id = label2 runat = server/>
</form></body>
</HTML>
执行结果
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: BC30676: “click”不是“System.Object”的事件。
源错误:
行 7:
行 8:
行 9: addhandler b.click, addressof b_click
行 10:
行 11: lable1.Controls.add(b)
源文件: E:\jsjj\Default.aspx 行: 9
|