| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1157 人关注过本帖
标题:哪位大虾能帮我研究一下下面这段代码错在哪里了,谢谢了
只看楼主 加入收藏
luohaifeng
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-1-8
收藏
 问题点数:0 回复次数:2 
哪位大虾能帮我研究一下下面这段代码错在哪里了,谢谢了
<script language ="vb" runat = "server">
     Sub Page_Load(sender As Object,e As EventArgs )
         If not Page.IsPostBack then
             MySelect1.Items.Add("1")
             MySelect1.Items.Add("2")
             MySelect1.Items.Add("3")
             MySelect1.Items.Add("4")
             MySelect2.Items.Add("1")
             MySelect2.Items.Add("2")
             MySelect2.Items.Add("3")
             MySelect2.Items.Add("4")
         End If
     End Sub               
     
     Sub btnTable_Click(sender As Object,e As EventArgs)
         Dim i,j,NumOfRow,NmOfCell As Integer
         Dim MyTableRow,MyTableCell As Object
         NumOfRow =(MySelect1.Value)
         NmOfCell =(MySelect2.Value)
         for j=1 to NumOfRow
             MyTableRow =new HtmlTableRow()
             for i=1 to NmOfCell
                 MyTableCell=new HtmlTableCell()
                 MyTableCell.InnerHtml=("第"+j+"行,第"+i+"列")
                 MyTableRow.Cells.Add(MyTableCell)
             Next
             MyHtmlTable1.Rows.Add(MyTableRow)
         Next
     End Sub
</script>
<html>
<head>
    <title>HTML中Table控件的使用</title>
</head>
<body id ="body1" runat ="server">
    <form id="form1" runat =server>
        <table id ="MyHtmlTable1" runat ="server" CellPadding="4" CellSpacing ="1" Border="1" BorderColor="Blue"/><P>
        </table>
        <b>行数:</b>
        <select id ="MySelect1" runat = "server"/><br>
        <b>列数:</b>
        <select id ="MySelect2" runat = "server"/>
        <input type ="submit" value ="生成新表格" OnServerClick="btnTable_Click" runat ="server">
    </form>
</body>
</html>


程序代码:
<SCRIPT language=vb runat="server">

     Sub Page_Load(sender As Object,e As EventArgs )
         If not Page.IsPostBack then 
             MySelect1.Items.Add("1")
             MySelect1.Items.Add("2")
             MySelect1.Items.Add("3")
             MySelect1.Items.Add("4")
             MySelect2.Items.Add("1")
             MySelect2.Items.Add("2")
             MySelect2.Items.Add("3")
             MySelect2.Items.Add("4")
         End If
     End Sub               
     
     Sub btnTable_Click(sender As Object,e As EventArgs)
         Dim i,j,NumOfRow,NmOfCell As Integer
         Dim MyTableRow,MyTableCell As Object
         NumOfRow =(MySelect1.Value)
         NmOfCell =(MySelect2.Value)
         for j=1 to NumOfRow
             MyTableRow =new HtmlTableRow()
             for i=1 to NmOfCell
                 MyTableCell=new HtmlTableCell()
                 MyTableCell.InnerHtml=("第"+j+"行,第"+i+"列")
                 MyTableRow.Cells.Add(MyTableCell)
             Next
             MyHtmlTable1.Rows.Add(MyTableRow)
         Next
     End Sub

</script>

搜索更多相关主题的帖子: Add 代码 Sub 
2005-01-08 10:35
regedit
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:950
专家分:0
注 册:2004-6-8
收藏
得分:0 

<script language ="vb" runat = "server"> Sub Page_Load(sender As Object,e As EventArgs ) If not Page.IsPostBack then MySelect1.Items.Add("1") MySelect1.Items.Add("2") MySelect1.Items.Add("3") MySelect1.Items.Add("4") MySelect2.Items.Add("1") MySelect2.Items.Add("2") MySelect2.Items.Add("3") MySelect2.Items.Add("4") End If End Sub Sub btnTable_Click(sender As Object,e As EventArgs) Dim i,j,NumOfRow,NmOfCell As Integer Dim MyTableRow as htmltablerow '这个变量类型定义错误 dim mytablecell as htmltablecell '这个变量类型定义错误 NumOfRow =cint(MySelect1.Value) '转为数字 NmOfCell =cint(MySelect2.Value) for j=1 to NumOfRow MyTableRow =new HtmlTableRow() for i=1 to NmOfCell MyTableCell=new HtmlTableCell() 'MyTableCell.InnerHtml="第"&j&"行,第"&i&"列" 'MyTableCell.Controls.Add(new LiteralControl("第" & j &"行,第" & i &"列"))

MyTableRow.Cells.Add(MyTableCell) Next MyHtmlTable1.Rows.Add(MyTableRow) Next End Sub </script> <html> <head> <title>HTML中Table控件的使用</title> </head> <body id ="body1" runat ="server"> <form id="form1" runat =server> <table id="MyHtmlTable1" CellPadding=4 CellSpacing=0 Border="1" runat="server" /><P> </table> <b>行数:</b> <select id ="MySelect1" runat = "server"/><br> <b>列数:</b> <select id ="MySelect2" runat = "server"/> <input type ="submit" value ="生成新表格" OnServerClick="btnTable_Click" runat ="server"> </form> </body> </html>

[此贴子已经被作者于2005-1-8 12:39:48编辑过]


最新作品:百货品牌商品资讯第一门户([url]http://www./[/url]),欢迎交流
2005-01-08 12:36
luohaifeng
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-1-8
收藏
得分:0 
    明白了,谢谢版主!
2005-01-08 17:19
快速回复:哪位大虾能帮我研究一下下面这段代码错在哪里了,谢谢了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015913 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved