| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 673 人关注过本帖
标题:请问,有谁能帮我修改一下代码,使得下面代码能显示出加减乘除 的结果是否正 ...
只看楼主 加入收藏
lin2012
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-3-29
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:5 
请问,有谁能帮我修改一下代码,使得下面代码能显示出加减乘除 的结果是否正确?
  Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n, m, op As Integer
        Dim x As New Random
        Label3.Text = ""
        n = Convert.ToInt16(100 * x.NextDouble())
        m = Convert.ToInt16(100 * x.NextDouble())
        TextBox1.Text = n.ToString()
        TextBox2.Text = m.ToString()
        op = Convert.ToInt16(1 + 3 * x.NextDouble())
        Select Case (op)
            Case 1
                Label1.Text = "+"
            Case 2
                Label1.Text = "-"
            Case 3
                Label1.Text = "*"
            Case 4
                Label1.Text = "/"
        End Select
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
      
        If (Convert.ToInt16(TextBox1.Text) + Convert.ToInt16(TextBox2.Text) = Convert.ToInt16(TextBox3.Text)) Then
            Label3.Text = "正确"
        Else
            Label3.Text = "错误"
        End If
         End Sub
End Class
搜索更多相关主题的帖子: Object Random 
2011-03-30 12:43
lin2012
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-3-29
收藏
得分:0 
If (Convert.ToInt16(TextBox1.Text) + Convert.ToInt16(TextBox2.Text) = Convert.ToInt16(TextBox3.Text)) or (Convert.ToInt16(TextBox1.Text) - Convert.ToInt16(TextBox2.Text) = Convert.ToInt16(TextBox3.Text)) or   (Convert.ToInt16(TextBox1.Text) * Convert.ToInt16(TextBox2.Text) = Convert.ToInt16(TextBox3.Text)) or (Convert.ToInt16(TextBox1.Text) / Convert.ToInt16(TextBox2.Text) = Convert.ToInt16(TextBox3.Text)) or   Then
2011-03-30 14:18
lin2012
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-3-29
收藏
得分:0 
!!!!!!!!!!!!
2011-03-30 14:23
ljgbluesky
Rank: 2
等 级:论坛游民
帖 子:10
专家分:40
注 册:2010-11-27
收藏
得分:20 
能把你做的界面也贴出来吗?
2011-03-30 22:33
lin2012
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-3-29
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册
  
2011-03-31 15:14
lowxiong
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:27
帖 子:653
专家分:3402
注 册:2008-5-7
收藏
得分:0 
  Inherits System.Web.UI.Page
    dim l as integer
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n, m, op As Integer
        Dim x As New Random
        Label3.Text = ""
        n = Convert.ToInt16(100 * x.NextDouble())
        m = Convert.ToInt16(100 * x.NextDouble())
        TextBox1.Text = n.ToString()
        TextBox2.Text = m.ToString()
        op = Convert.ToInt16(1 + 3 * x.NextDouble())
        Select Case (op)
            Case 1
                Label1.Text = "+"
                l=n+m
            Case 2
                Label1.Text = "-"
                l=n-m
            Case 3
                l=n*m
                Label1.Text = "*"
            Case 4
                l=n/m
                Label1.Text = "/"
        End Select
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
      
        If val(TextBox3.Text))=l Then
            Label3.Text = "正确"
        Else
            Label3.Text = "错误"
        End If
    End Sub
End Class
2011-04-10 09:55
快速回复:请问,有谁能帮我修改一下代码,使得下面代码能显示出加减乘除 的结果 ...
数据加载中...
 
   



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

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