VB中怎么将两个文本框中的数字相加在第三个文本框中显示
答案:3 悬赏:20
解决时间 2021-04-07 22:06
- 提问者网友:℡她的他i☆
- 2021-04-07 08:08
VB中怎么将两个文本框中的数字相加在第三个文本框中显示
最佳答案
- 二级知识专家网友:荒唐后生
- 2021-04-07 09:18
Private Sub Command1_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub 文本框的值是文本类型,想要相加必须先转换成数值类型。
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub 文本框的值是文本类型,想要相加必须先转换成数值类型。
全部回答
- 1楼网友:白日梦制造商
- 2021-04-07 11:31
Text3.text=val(Text1.text)+val(Text2.text)
- 2楼网友:樣嘚尐年
- 2021-04-07 10:33
先说下我的做法
窗体上有三个text,三个command text1输入你任意你想的数字,不同数字间用一个空格隔开
text2和text1是一样的 text3中输出两个文本框相同的数字,不同数字之间是写一个空格隔开的
程序使用: 1,按下command2此时会提醒在text1中输入你想要的数字 2,按下command3此时会提醒在text2中输入你想要的数字 3,按下command3此时就会显示两文本框中相同的数字
程序如下: 已测试通过,希望能对你有所帮助
function f(a as string, b as string) as integer
dim s() as string, i%, j%
dim y() as string
s = split(a, " ")
y = split(b, " ")
for i = 0 to ubound(s)
for j = 0 to ubound(y)
if s(i) = y(j) then
text3.text = text3.text & " " & s(i)
goto h
end if
next j
h: next i
end function
private sub command1_click()
dim i as integer
i = f(text1.text, text2.text)
end sub
private sub command2_click()
print "请输入text1里的数,不同的数用空格分开"
text1.text = ""
text3.text = ""
text1.setfocus
end sub
private sub command3_click()
print "请输入text2里的数,不同的数用空格分开"
text2.text = ""
text2.setfocus
end sub
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯