主题: 怎么让第三个文本框显示前两个数字的相加
来源:学生作业帮助网 编辑:作业帮 时间:2024/05/11 01:15:36
主题: 怎么让第三个文本框显示前两个数字的相加
主题: 怎么让第三个文本框显示前两个数字的相加
主题: 怎么让第三个文本框显示前两个数字的相加
有三个文本框,在前两个输入数字后,点击按钮,结果会显示在第三个文本框中,可是下面这段代码不识别小数点,如果能识别小数点相加
全部展开
]
收起
比如说 第一个文本框 TextBox1 第二个是TextBox2 TextBox3 加一个按钮 在按钮事件下写 TextBox3.Text=(Convert.ToInt32(TextBox2.text)+Convert.ToInt32(TextBox1.Text)).ToString(); 这样就OK了]
Option Explicit\4\3\4\3Private Sub Command1_Click()\4\3 Dim t1%, t2%, t3%, t4%, t5%, t6%, v%(3)\4\3 Dim s1$(), s2$(), s3$(), s4$(), s5$(), s6$(), st$(1)\4\3 'Text8 = "" '若想用text显示请去掉Text8前的注...
全部展开
Option Explicit\4\3\4\3Private Sub Command1_Click()\4\3 Dim t1%, t2%, t3%, t4%, t5%, t6%, v%(3)\4\3 Dim s1$(), s2$(), s3$(), s4$(), s5$(), s6$(), st$(1)\4\3 'Text8 = "" '若想用text显示请去掉Text8前的注释\4\3 List1.Clear 'text显示速度太慢,改用listbox显示\4\3 s1 = Split(Text1, ","): s2 = Split(Text2, ",")\4\3 s3 = Split(Text3, ","): s4 = Split(Text4, ",")\4\3 s5 = Split(Text5, ","): s6 = Split(Text6, ",")\4\3 v(1) = InStr(1, Text7, "-")\4\3 v(2) = Val(Left(Text7, v(1) - 1))\4\3 v(1) = Val(Mid(Text7, v(1) + 1))\4\3 For t1 = 0 To UBound(s1)\4\3 For t2 = 0 To UBound(s2)\4\3 If s2(t2) = s1(t1) Then Exit For\4\3 For t3 = 0 To UBound(s3)\4\3 If s3(t3) = s1(t1) Or s3(t3) = s2(t2) Then Exit For\4\3 For t4 = 0 To UBound(s4)\4\3 If s4(t4) = s1(t1) Or s4(t4) = s2(t2) Or s4(t4) = s3(t3) Then Exit For\4\3 For t5 = 0 To UBound(s5)\4\3 If s5(t5) = s1(t1) Or s5(t5) = s2(t2) Or s5(t5) = s3(t3) Or s5(t5) = s4(t4) Then Exit For\4\3 For t6 = 0 To UBound(s6)\4\3 If s6(t6) = s1(t1) Or s6(t6) = s2(t2) Or s6(t6) = s3(t3) Or s6(t6) = s4(t4) Or s6(t6) = s5(t5) Then Exit For\4\3 v(3) = Val(s1(t1)) + Val(s2(t2)) + Val(s3(t3))\4\3 v(3) = v(3) + Val(s4(t4)) + Val(s5(t5)) + Val(s6(t6))\4\3 If v(2) <= v(3) And v(3) <= v(1) Then\4\3 v(0) = v(0) + 1\4\3 st(0) = s1(t1) & "+" & s2(t2) & "+" & s3(t3) & "+" & s4(t4)\4\3 st(0) = st(0) & "+" & s5(t5) & "+" & s6(t6) & "=" & v(3) & vbCrLf\4\3 'st(1) = st(1) & st(0) '若想用text显示请去掉st(1)前的注释\4\3 List1.AddItem st(0) 'text显示速度太慢,改用listbox显示\4\3 End If\4\3 Next\4\3 Next\4\3 Next\4\3 Next\4\3 Next\4\3 Next\4\3 'Text8 = st(1) '若想用text显示请去掉Text8前的注释\4\3 Label1 = Str(v(0))\4\3End Sub\4\3\4\3Private Sub Form_Load()\4\3 Text1 = "1,2,3,4,5,6,7,8,9,10"\4\3 Text2 = "12,13,14,15,16,17,18,19,10"\4\3 Text3 = "21,23,24,25,16,17,18,19,10,11"\4\3 Text4 = "31,33,34,25,17,19"\4\3 Text5 = "32,34,26,18,49"\4\3 Text6 = "11,27,34,18,23"\4\3 Text7 = "150-200"\4\3End Sub\4\3是不是你想要的?]
收起