绑定文本框 [英] Bound text box

查看:93
本文介绍了绑定文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设表单上有3个控件....


Textbox1,Textbox2和Textbox3


如果你想让Textbox3等于Val (Textbox1)+ Val(Textbox2)..


如何将其硬编码到Textbox3?

Assume 3 controls on a form....

Textbox1, Textbox2, and Textbox3

If you want Textbox3 to equal Val(Textbox1) + Val(Textbox2)..

How do you hardcode this to Textbox3 ?

推荐答案

假设您已经验证了前两个文本框的确如此,实际上

包含数字数据:


Textbox3.Text = CType(Textbox1.Text,Double )+ CType(Textbox2.Text,Double)


或者,为了更好的异常管理:


Dim x,y,z As Double

尝试

x = CType(Textbox1.Text,Double)

y = CType(Textbox2.Text,Double)

z = x + y

Catch e As Exception

Textbox3.Text ="您必须只输入数字数据!"

结束尝试

" Rob" < RW ***** @ comcast.net>在消息中写道

新闻:AI ******************** @ comcast.com ...
Assuming you have already validated that the first 2 textboxes do, in fact
contain numeric data:

Textbox3.Text = CType(Textbox1.Text, Double) + CType(Textbox2.Text, Double)

Or, for better exception management:

Dim x, y, z As Double
Try
x = CType(Textbox1.Text, Double)
y = CType(Textbox2.Text, Double)
z= x + y
Catch e As Exception
Textbox3.Text = "You must enter only numeric data!"
End Try
"Rob" <rw*****@comcast.net> wrote in message
news:AI********************@comcast.com...
假设表单上的3个控件....

Textbox1,Textbox2和Textbox3

如果您希望Textbox3等于Val(Textbox1)+ Val(Textbox2)..

如何将其硬编码到Textbox3?
Assume 3 controls on a form....

Textbox1, Textbox2, and Textbox3

If you want Textbox3 to equal Val(Textbox1) + Val(Textbox2)..

How do you hardcode this to Textbox3 ?



谢谢Scott,


我的& ;实"问题是......你把代码放在哪里?让我们说你是使用设计师的
...我可以把'= CType(Textbox1.Text,Double)+

CType(Textbox2.Text,双)"进入TextBox3的属性......或者必须是

事件驱动(即点击)


" Scott M." < S - *** @ nospam.nospam>在消息中写道

news:uW **************** @ TK2MSFTNGP10.phx.gbl ...
Thanks Scott,

My "real" question is.... where do you put the code ? Let''s say you are
using the designer... May I put "= CType(Textbox1.Text, Double) +
CType(Textbox2.Text, Double)" into a property of TextBox3... or must it be
Event driven (i.e., "On Click")

"Scott M." <s-***@nospam.nospam> wrote in message
news:uW****************@TK2MSFTNGP10.phx.gbl...
假设你有已验证前两个文本框实际上是否包含数字数据:

Textbox3.Text = CType(Textbox1.Text,Double)+ CType(Textbox2.Text,
Double)

或者,为了更好的异常管理:

Dim x,y,z As Double
尝试
x = CType(Textbox1.Text, Double)
y = CType(Textbox2.Text,Double)
z = x + y
Catch e As Exception
Textbox3.Text ="您必须只输入数字数据!
结束尝试

" Rob" < RW ***** @ comcast.net>在消息中写道
新闻:AI ******************** @ comcast.com ...
Assuming you have already validated that the first 2 textboxes do, in fact
contain numeric data:

Textbox3.Text = CType(Textbox1.Text, Double) + CType(Textbox2.Text,
Double)

Or, for better exception management:

Dim x, y, z As Double
Try
x = CType(Textbox1.Text, Double)
y = CType(Textbox2.Text, Double)
z= x + y
Catch e As Exception
Textbox3.Text = "You must enter only numeric data!"
End Try
"Rob" <rw*****@comcast.net> wrote in message
news:AI********************@comcast.com...
假设有3个控件表单....

Textbox1,Textbox2和Textbox3

如果你想让Textbox3等于Val(Textbox1)+ Val(Textbox2)..

你如何将其硬编码到Textbox3?
Assume 3 controls on a form....

Textbox1, Textbox2, and Textbox3

If you want Textbox3 to equal Val(Textbox1) + Val(Textbox2)..

How do you hardcode this to Textbox3 ?




一个简单的方法是在textbox1的textchanged事件中和textbox2

" Rob" < RW ***** @ comcast.net>在消息中写道

新闻:Q5 ****************************** @ comcast.com。 ..
A simple way to do it is in the textchanged event of textbox1 and textbox2
"Rob" <rw*****@comcast.net> wrote in message
news:Q5******************************@comcast.com. ..
谢谢Scott,

我的真实问题是......你把代码放在哪里?让我们说你是使用设计师......我可以把'= CType(Textbox1.Text,Double)+
CType(Textbox2.Text,Double)"进入TextBox3的属性......或者必须是
事件驱动(即On Click)

Scott M. < S - *** @ nospam.nospam>在消息中写道
新闻:uW **************** @ TK2MSFTNGP10.phx.gbl ...
Thanks Scott,

My "real" question is.... where do you put the code ? Let''s say you are
using the designer... May I put "= CType(Textbox1.Text, Double) +
CType(Textbox2.Text, Double)" into a property of TextBox3... or must it be
Event driven (i.e., "On Click")

"Scott M." <s-***@nospam.nospam> wrote in message
news:uW****************@TK2MSFTNGP10.phx.gbl...
假设您已经验证了前两个文本框,
事实包含数字数据:

Textbox3.Text = CType(Textbox1.Text,Double)+ CType(Textbox2.Text,
Double)
Dim x,y,z As Double
尝试
x = CType(Textbox1.Text,Double)
y = CType(Textbox2.Text,Double)
z = x + y
Catch e As Exception
Textbox3.Text ="您必须只输入数字数据!
结束尝试

" Rob" < RW ***** @ comcast.net>在消息中写道
新闻:AI ******************** @ comcast.com ...
Assuming you have already validated that the first 2 textboxes do, in fact contain numeric data:

Textbox3.Text = CType(Textbox1.Text, Double) + CType(Textbox2.Text,
Double)

Or, for better exception management:

Dim x, y, z As Double
Try
x = CType(Textbox1.Text, Double)
y = CType(Textbox2.Text, Double)
z= x + y
Catch e As Exception
Textbox3.Text = "You must enter only numeric data!"
End Try
"Rob" <rw*****@comcast.net> wrote in message
news:AI********************@comcast.com...
假设有3个控件表单....

Textbox1,Textbox2和Textbox3

如果你想让Textbox3等于Val(Textbox1)+ Val(Textbox2)..

如何将其硬编码到Textbox3?
Assume 3 controls on a form....

Textbox1, Textbox2, and Textbox3

If you want Textbox3 to equal Val(Textbox1) + Val(Textbox2)..

How do you hardcode this to Textbox3 ?





这篇关于绑定文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆