⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 19vb.aspx

📁 这是该书上的所有源代码,不错
💻 ASPX
字号:
<%@ Page Language="VB" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<html>
<title>第十九例 LinkButton ImageButton ListBox Label控件的使用</title>
<head>
   <script language="VB" runat="server">
	 Dim Shared a As Integer
	 Dim Shared b As Integer
	 Dim Shared c As Integer
	 Dim Shared d As Integer
		'定义四个静态全局变量,用以代表四个随机数
      Sub Page_Load(sender As Object, e As EventArgs)
		If Not IsPostBack then
		Dim dt As ArrayList = new ArrayList()
		dt.Add("+")
		dt.Add("-")
		   ListBox1.DataSource = dt
		   ListBox1.DataBind
		   ListBox2.DataSource = dt
		   ListBox2.DataBind
		   ListBox3.DataSource = dt
		   ListBox3.DataBind
		End If
      End Sub  '页面初始化,对各ListBox控件绑定数据

      Function Cal1(sender As ListBox,a As Integer,b As Integer) As Integer
	 If sender.SelectedIndex=0 then
		Return a+b
	 Else
		Return a-b
	 End If
      End Function  '定义了一个运算函数

      Sub ImageButton_Click(sender as object,e as ImageClickEventArgs)
	 Label6.text=""	
	 Randomize
	 a = int(9*rnd()+1)
	 b = int(9*rnd()+1)
	 c = int(9*rnd()+1)
	 d= int(9*rnd()+1)
         Label1.Text = a.toString
         Label2.Text = b.toString
         Label3.Text = c.toString
         Label4.Text = d.toString
	 If a+b+c+d <24 then
           Label5.text="无解!"
	   return
	 Else If a+b+c+d>24 then
	   If a+b+c-d <> 24 then
		Label5.text="无解!"
		return
	   Else If a+b-c+d <> 24 then
		Label5.text="无解!"
		return
	   Else If a-b+c+d <> 24 then
		Label5.text="无解!"
		return
	   End If
	 End If
           Label5.text=" = 24"
 	   ImageButton1.visible=false
      End Sub	'ImageButton事件,用来生成随机数,并进行校验

      Sub s1(sender as object,e as EventArgs)
		If Cal1(Listbox3,Cal1(Listbox2,Cal1(Listbox1,a,b),c),d)=24 then
		ImageButton1.visible=true
		Label6.text="输入正确!"
	 Else
		ImageButton1.visible=false
		Label6.text="输入错误,请重新输入!"
	 end If
      End Sub	'当有解时,看输入是否正确

   </script>

</head>

<body>

   <form runat="server">

      <h3><font face="Verdana">第十九例 LinkButton ImageButton ListBox Label控件的使用</font></h3>

      <asp:Label id="Label1" Font-Size="14pt" runat="server"/>
      <asp:ListBox id="ListBox1" Rows="1" Width="50px" SelectionMode="Single" runat="server"/>
      <asp:Label id="Label2" Font-Size="14pt" runat="server"/>
      <asp:ListBox id="ListBox2" Rows="1" Width="50px" SelectionMode="Single" runat="server"/>
      <asp:Label id="Label3" Font-Size="14pt" runat="server"/>
      <asp:ListBox id="ListBox3" Rows="1" Width="50px" SelectionMode="Single" runat="server"/>
      <asp:Label id="Label4" Font-Size="14pt" runat="server"/>
      <asp:Label id="Label5" runat="server"> = 24</asp:label>
      <asp:LinkButton id="LinkButton1" Text="提交" Font-Name="Verdana" Font-Size="14pt" runat="server" onclick="s1"/>
      <asp:ImageButton id="imagebutton1" runat="server" AlternateText="ImageButton 1" ImageAlign="left" ImageUrl="button1-1.gif" onmouseover="this.src='button1-2.gif';" onmouseout="this.src='button1-1.gif';" OnClick="ImageButton_Click"/>
      <br>
      <asp:Label id="Label6" runat="server"/>
   </form>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -