如何在第3个文本字段中添加2个textfeld数据和结果显示 [英] how to add 2 textfeld data and result show in 3rd one textfield
本文介绍了如何在第3个文本字段中添加2个textfeld数据和结果显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在两个文本字段中给出数字数据并在第三个文本字段中给出结果
解决方案
像这样的东西(只是一个样本);)
加价:
< asp:textbox id = txt1 runat = 服务器 > < / asp:textbox >
< asp:label runat = < span class =code-keyword> server text = + > < / asp:label >
< asp:textbox id = txt2 runat = server > < / asp:textbox >
< asp:按钮 id = btnAdd runat = server text = = / >
< asp:textbox id < span class =code-keyword> = txt3 runat = server > < / asp:textbox >
代码落后:
私有 Sub btnAdd_Click( ByVal sender < span class =code-keyword>作为 对象, ByVal e As System.EventArgs)句柄 btnAdd.Click
Dim int1,int2 作为 整数
如果 Int32 .TryParse(txt1.Text,int1) AndAlso Int32 .TryParse(txt2.Text,int2)然后
Dim 结果作为 整数 = int1 + int2
txt3.Text = result.ToString
结束 如果
结束 Sub
也许这个会做..(只是一个样本)
textbox3.text = Val (textbox1.text)+ Val(textbox2.text)
如果你真正问的就是那么简单。
i want to give numeric data in two text field and give result in 3rd textfield
解决方案
Something like this (just a sample) ;)
Markup :
<asp:textbox id="txt1" runat="server"></asp:textbox> <asp:label runat="server" text="+"></asp:label> <asp:textbox id="txt2" runat="server"></asp:textbox> <asp:button id="btnAdd" runat="server" text="=" /> <asp:textbox id="txt3" runat="server"></asp:textbox>
Code behind :
Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim int1, int2 As Integer If Int32.TryParse(txt1.Text, int1) AndAlso Int32.TryParse(txt2.Text, int2) Then Dim result As Integer = int1 + int2 txt3.Text = result.ToString End If End Sub
Maybe this one would do.. (Just a sample)
textbox3.text= Val(textbox1.text) + Val(textbox2.text)
if what you're really asking is just that simple.
这篇关于如何在第3个文本字段中添加2个textfeld数据和结果显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文