以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求一偏方:怎样实现一个文本框的数值发送数字到另个文本框并且使它每次都加发送的值,谢谢  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=85102)

--  作者:limit_1982
--  发布时间:2016/5/17 22:44:00
--  求一偏方:怎样实现一个文本框的数值发送数字到另个文本框并且使它每次都加发送的值,谢谢

数值只在控件上面临时增加的

比如:每次按按钮,就从文本框1数字就在文本框2中增加

Dim d10 As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim je As WinForm.TextBox = e.Form.Controls("TextBox2")    ‘初始值是0

Dim s(1) As String
Dim n As Integer
s(0)= d10.Text
s(1) =je.Text
For i As Integer = 0 To 1
    If IsNumeric(s(i)) Then
        d10.Text = d10.Text+ Val(s(i))
    End If
Next

 

 

哪里错了,谢谢

 

 


--  作者:limit_1982
--  发布时间:2016/5/17 22:48:00
--  

Dim d10 As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim je As WinForm.TextBox = e.Form.Controls("TextBox2")
Dim s(1) As String
Dim n As Integer
s(0)= d10.Text
s(1) =je.Text
For i As Integer = 0 To 1
    If IsNumeric(s(i)) Then
        d10.Text =je.Text+ Val(s(0))
    End If
Next

 

可以了,谢谢    ,目的实现了,不知道代码是否是多余?

[此贴子已经被作者于2016/5/17 22:50:08编辑过]

--  作者:大红袍
--  发布时间:2016/5/17 22:49:00
--  

直接写

 

Dim d10 As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim je As WinForm.TextBox = e.Form.Controls("TextBox2")    \'初始值是0
je.text = val(je.text) + val(d10.text)


--  作者:xiaoohoo
--  发布时间:2016/5/17 22:51:00
--  
        Dim d10 As WinForm.TextBox = e.Form.Controls("TextBox1")
        Dim je As WinForm.TextBox = e.Form.Controls("TextBox2")    \'初始值是0


        d10.Value = IIf(IsNumeric(d10.Value), Val(d10.Value), 0) + IIf(IsNumeric(je.Value), Val(je.Value), 0)